-
Notifications
You must be signed in to change notification settings - Fork 5
perf(form): improve performance of editor inputs #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
24ecd62 to
36a8a1e
Compare
36a8a1e to
eeb8c74
Compare
formule-demo/src/App.tsx
Outdated
| <Typography.Text strong>Form data</Typography.Text> | ||
| <CodeViewer | ||
| value={JSON.stringify(formuleState?.formData, null, 2)} | ||
| value={JSON.stringify(getFormuleState().formData, null, 2)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getFormuleState why change this, since formuleState is used around ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SchemaSynchronizer does not update the synced state when the formData updates so now we need to get it directly from formule and not from formuleState
src/StateSynchronizer.jsx
Outdated
|
|
||
| useEffect(() => { | ||
| synchronizeState(state); | ||
| const prev = previousStateRef.current; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's to filter out formData updates from the state sync and avoid updating the state continuously when typing
|
also lets try fix the test |
When typing or interacting with a big form in the editor the performance became poor, making the inputs feel laggy. This was caused by many unnecessary rerenders of many different field components in reaction to
formDataupdates. This PR implements the following changes to address this performance degradation:formDatastate updates on form input changes in editor (EditablePreview).TextWidgetandSelectWidgetby only subscribing toformDatachanges in case they have autofill or a suggestions endpoint configured, respectively, since it is not needed otherwise.persistMiddleware(which saves schemas to localStorage on change) when the action isupdateFormData, removing many unnecessary saves.StateSychronizernot trigger when onlyformDatahas changed. This means if we want to accessformDatafrom an app we have to fetch it directly from formule (getFormuleState().formData), and not from the synced state.These changes greatly improve the performance for big schemas. However, there is still room for improvement, as
formDataupdates can still make the field laggy for a fraction of a second when the debounce fires.