[Form lib] Memoize form hook object and fix hook array deps#71237
[Form lib] Memoize form hook object and fix hook array deps#71237sebelga merged 17 commits intoelastic:masterfrom
Conversation
|
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
There was a problem hiding this comment.
@sebelga awesome work!
Definitely tricky to spot runtime staleness errors if there are any 😅 but the proposed changes all look good to me and I'm glad we could tackle this issue!
I clicked through different forms in the mappings editor and in ingest processors editor and they seemed to work as expected.
|
Thanks for the review @jloleysens ! Yes it is tricky to detect. I had quite a few console.log() to detect infinite re-renders, and got a few of them solved. I admit that there is a problem with the data flow inside the lib that I'd like to address in |
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
|
@sebelga I believe the test failures are valid, as the |
|
@elasticmachine merge upstream |
yctercero
left a comment
There was a problem hiding this comment.
Thanks so much for the updates! This is much cleaner. I did notice a few react warnings pop up in the step_about_rule that I don't think were there before (just quickly checked against a master). Not sure if they're related to the changes?
|
Thanks for the review @yctercero ! I will check those React warnings 👍 |
| isNew: false, | ||
| }; | ||
| setMyStepData(myDefaultValues); | ||
| setFieldValue(form, schema, myDefaultValues); |
There was a problem hiding this comment.
@sebelga we have this pattern in several of these "rule creation step" forms. Do you intend to change the others after we verify this one?
There was a problem hiding this comment.
@rylnd We will have to. setFieldValue was probably a hack that you had to create because of an unexpected behaviour on the form lib. Now that all the handlers are memoized and the form object too, this hack is not necessary anymore. I will review it tomorrow with Patryk.
There was a problem hiding this comment.
@sebelga yes, absolutely! Very excited to clean things up once this is merged 🙏
…memoize # Conflicts: # x-pack/plugins/security_solution/public/cases/components/add_comment/index.tsx # x-pack/plugins/security_solution/public/cases/components/create/index.tsx # x-pack/plugins/security_solution/public/cases/components/user_action_tree/user_action_markdown.tsx
💚 Build SucceededBuild metricsasync chunks size
miscellaneous assets size
page load bundle size
History
To update your PR or re-run it, just comment with: |
stephmilovic
left a comment
There was a problem hiding this comment.
Case files and manual testing of the case forms all LGTM, thanks!
|
Thanks for the review @stephmilovic ! |
* master: [Form lib] Memoize form hook object and fix hook array deps (elastic#71237) [uiActions] Support emitting nested triggers and actions (elastic#70602) add short sleep before clicking Remove on sample data (elastic#71104) Fixed the beta badge layout. (elastic#71835) Restores task for downloading Chromium builds (elastic#71749) [logging] Format new platform json logging to ECS (elastic#71138) add policy details and update SO limit requests (elastic#71789) Convert vis_type_vega to Typescript (elastic#68915) [ML] Fix UI Actions context menu positioning for the Anomaly Swim Lane (elastic#71839)
This PR correctly memoize the handlers and variables of the form lib hooks. It also declares the correct hooks deps to get us one step closer to close #49554
I have also updated the forms of index management to correctly declare their
useEffectdeps.How to test
There isn't an easy way to test. We need to go through different forms and make sure everything works as expected. I have already spent a large amount of time testing the index templates forms, mainly the mappings editor forms.