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;

Related Query

More Query from same tag