I try to get value from backend and append the result to the input field value, but it will not be updated.
Currently I use Ant Design Forms and if input field is moved out of Form it works.
import { version, Input, Form } from "antd";
function View() {
const [LegalName, setLegalName] = useState("");
useEffect(() => {
axios
.get("/afterlogin/OrgFullPictureGet/3", config)
.then(response => {
setLegalName(response.data.name);
})
.catch(error => {
// console.log(error.response.data.errors);
});
}, []);
const onFinish = values => {
//onFinish logic here
console.log(values);
};
return (
<div className="App">
<Form name="nest-messages" onFinish={onFinish}>
<Form.Item
name={["user", "LegalName"]}
label={<span>Legal Name</span>}
>
<Input
placeholder={"Your business legal name"}
value={LegalName}
onChange={e => setLegalName(e.target.value)}
/>
</Form.Item>
</Form>
</div>
);
}
the value does not get appended on the input field
response.data.nameinsidethen?