react
react copied to clipboard
FormEdit isn't updated with server data
The test case
const [form, setForm] = useState({display: 'form'});
const [saveText, setSaveText] = useState('Create Form');
useEffect(() => {
async function getFormBuilderData()
{
const res = await axios.get('/api/editor');
setForm(res.data);
}
getFormBuilderData();
}, []);
return <>
<FormEdit form={form} saveText={saveText} saveForm={saveForm} options={{
builder: {
layout: false,
premium: false,
data: false,
}
}}
I can't see saved controls. I think the issue in the next code section of FormEdit: https://github.com/formio/react-formio/blob/master/src/components/FormEdit.jsx
shouldComponentUpdate(nextProps, nextState, nextContext) {
// Only update if key form info has changed. The builder handles form component changes itself.
return (
this.state.form.title !== nextState.form.title ||
this.state.form.name !== nextState.form.name ||
this.state.form.path !== nextState.form.path ||
this.state.form.display !== nextState.form.display ||
this.state.form.type !== nextState.form.type
);
}
or this
static getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.form && (prevState.form._id !== nextProps.form._id || prevState.form.modified !== nextProps.form.modified)) {
return {
form: _cloneDeep(nextProps.form),
};
}
return null;
}
None of them checks controls difference. getDerivedStateFromProps set state only if new object has modified or _id properties
@Andrey-Pavlov,
We have added this item to our backlog. We welcome a pull request for this item to be resolved or we have a process to expedite this issue if you are interested. Please contact [email protected] if you would like the price to expedite this for you.
Thank you,
William Gay
@Andrey-Pavlov @wag110894 There is no start script while I downloaded the sorce code , So i add a custom webpack file and run the application But which is the main file that is responsible for the page loading so that i can customize the whole components inside project ...Can you pls let me know
@rahulseth625 This repository is just a library. It isn't meant to be used as an actual application. You should use components from this library to utilize your own react application.
I am closing the issue as it was created too long ago and there are no new comments here. I hope it was resolved. If not, please reopen it. Thanks!
Hello @TanyaGashtold. It was not fixed but I changed multiple projects, workplaces and got a child. Thank you.