score:0
you can use a state and set him with the data from your sever and put the value you want to display on property value of your autocomplete.
say me if i miss the trouble you have, i can edit again.
score:0
make use of 'value' prop of autocomplete component, and pass the value that you want to show in edit mode as object of option, here's is a small example
jsx
import { usestate } from "react";
import { autocomplete, textfield } from "@mui/material";
const options = [
{ label: "the godfather", id: 1 },
{ label: "pulp fiction", id: 2 },
];
const app = ({ editmode = true }) => {
const [fieldvalue, setfieldvalue] = usestate(editmode ? options[1] : null);
return (
<div classname="app">
<autocomplete
disableportal
options={options}
onchange={(e, value) => {
console.log(value);
setfieldvalue(value);
}}
value={fieldvalue}
renderinput={(params) => (
<textfield
onchange={(e) => setfieldvalue(e.target.value)}
label="hello"
{...params}
/>
)}
/>
</div>
);
};
export default app;
Source: stackoverflow.com
Related Query
- dynamically change Mui Autocomplete value selection
- Make mui autocomplete persist the input value after selection
- Change cell value dynamically in MUI Data Grid
- Change primary color dynamically in MUI theme
- Autocomplete Mui Testing, simulate change doesn't work
- How can I dynamically change the value of a CSS property in React?
- How can I dynamically change property value in an object in Material UI?
- Change the color of MUI Autocomplete option
- MUI Select | Change how the selected value display in Input
- MUI async Autocomplete and react-hook-form: Form can't access Autocomplete value
- MUI Autocomplete remove option after selection
- ReactJS Material UI how to prevent Autocomplete to change the value
- How to dynamically change animation value in inline syle of ReactJS
- Material UI Autocomplete change selected value of one autocomplete when value is changed in another autocomplete
- Dynamically change image source based on boolean value
- How to dynamically change css selector property value in react js code?
- Change a JSON value with an MUI Switch component
- How to get mui Chip value before delete on Autocomplete freeSolo?
- how to change the row property value of textarea dynamically according to text input? [In ReactJS]
- Unable to change decimal value in MUI v5 TextField
- Change the appearance of the MUI Autocomplete components GroupLabels in React
- MUI Typography color change on selection
- How to change value from array of object on drop down list selection ReactJS
- Default value of Autocomplete is undefined in MUI v5
- Dynamically change value in Formik when a state changes
- React question. How to change the interval value in setInterval dynamically
- MUI Autocomplete not updating selected value when switching selected values between 2 autocomplete components
- Change buttons dynamically using responseData index and length - React autocomplete
- React map method Render Input dynamically change value separate fields
- Nodejs - How to acquire ID property whenever you change the value on a selection option object
More Query from same tag
- React: How to make item like m2, km2 (have the number 2 in the top right of letter 'm')
- How to display and animate React Component depending to result of condition with React Spring?
- React-Redux - A component is changing a controlled input of type text to be uncontrolled
- React useState Hooks with JSON data outputting array of arrays instead of one array
- Using spread operators for redux in react? Array mapping problems?
- How to catch HTTP response error and then pass to the caller
- Why doesn't the onClick action add a value to an existing integer
- You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file (.css, .png , .html)
- How can I give a key in JSX the value of a variable depending on conditions
- React Server side rendering with Express - warning on the client checksum & Styling
- Can't remove scrollbar from Material UI Dialog
- How to stop executing a command the contains useState?
- reactjs with material ui - appbar doesn't support gradients
- How to enable Redux Devtools?
- Where is the CSS produced from SCSS located?
- react-sortable-tree Crud Operation using hooks
- change the color when onClick() with React
- Object is possibly null using "useEffect"
- error in implementing seconds countdown using state in react
- React routing not loading pages
- formik-material-ui not working for TogglleButtonGroup Component
- beforeEach not executing in jest
- Mock-testing the catch block of a promise method
- Jest can't use the HOC from js files but works correctly with HOC from tsx files
- Send multiple axios requests in a for loop in series (One after the other)
- React-Select if value exists show value if not show placeholder text
- Pass url param to React.js root component
- window is not defined - react-draft-wysiwyg used with next js (ssr)
- Laravel 8 controller api returning "page not found" in axios react
- Fragments giving Unexpected token error in React 16.2