-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Remove safeRenderCompletion and setImmediate hacks #1197
Comments
safeRenderCompletion
and setImmediate
hacks
safeRenderCompletion
and setImmediate
hacks
Thanks for making this issue. Do you know why exactly the custom |
No, I don't know why. Some forensics:
If I understand everything correctly:
Regarding backwards compatibility: In theory, after eliminating This is even more true if we take new React hooks into consideration, which could be a solution for the performance problem, since this requires upgrading the peer dependency on React to 16.8.0. |
After just spending three hours debugging why some keystrokes were skipped when typing rapidly in our complex form and then discovering the need for |
Thanks for digging into this. I never really understood the purpose of those hacks myself. I'd love to see them gone. |
by changing to proper use of setState() without setImmediate() hacks (see rjsf-team#1197)
* react-dom is external peerDependency, just like react. fixes version conflicts, e.g. I got an error Uncaught TypeError: this.updater.enqueueCallback is not a function when using setState callback because I use React 16.x and react-jsonschema-form bundled react-dom 15.x See facebook/react#10320 (comment) * Fix for new submit() method (PR #1058) also submitting the HTML form ..., navigating away from current page at least in Firefox. Reason: dispatched event was not cancelable, so preventDefault in onSubmit couldn't cancel it. Links: * <https://stackoverflow.com/a/40916998> * <https://developer.mozilla.org/en-US/docs/Web/API/Event/cancelable> * Synchronous call to onSubmit() from props Due to the use of setImmediate() hack in setState utility function (utils.js), onSubmit() handler from props is called asynchronously. This leads to massive problems for operations requiring "trusted events", like window.open() or programmatically submitting forms with target "_blank" (which we needed) Because onSubmit() should not need the performance-related setImmiate() hack, I replaced call to setState utility function with proper this.setState() from React. * fix failing FileWidget tests by changing to proper use of setState() without setImmediate() hacks (see #1197) * fix input type, fix test name * Test with newer node versions * Add node 12
This is nearly fixed by #1454, but we still have a few setImmediate hacks in the playground and tests that need to be removed: https://github.com/rjsf-team/react-jsonschema-form/search?q=setImmediate&unscoped_q=setImmediate |
This is a proposal for V2 project, where's the chance to get rid of
setImmediate
hacks regardingsetState
:setState
wrapper (which usessetImmediate
hack) with proper ReactsetState
calls and with callback where appropriate, and eliminatesetState
wrapper.safeRenderCompletion
setImmediate
hacks (at least outside of testing code)The code to be removed makes assumptions about React behaviour and JS engine performance which don't work as they changed (and will change) over time.
See discussion at #891 (older: #562)
Related currently open issues: #1164, #1023 (maybe), #544, #513 (maybe), #446 I'm sure there are many other (potentially obscure) errors, mostly race-conditions, coming from this hack. See for example my PR #1068.
There's the possibility that bugs are raised or performance is degraded by that change, but these problems should always be fixable without a false
setImmediate
"fix".P.S: nice to see that the project gains traction again, thanks for all working on it. We're happy to contribute!
The text was updated successfully, but these errors were encountered: