-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
ReactDOMServer.renderToString: presence of onClick handler causes errors on async update #5473
Comments
This line tries to get a node that is not mounted:
|
Yeah, I suppose setState should warn and do nothing. What did you expect would happen though? |
Not only I expect asynchronous updates to be ignored (with a warning) on components rendered using |
I also ran into this error when trying to update a codebase to make use of server-side rendering. There was a counter using I had trouble tracking the problem down as the error is pretty confusing in this case. Some sort of warning when |
In dev mode, we could mark a component as having been rendered using SSR. If |
Hello, first attempts to dive into react sources here :) I took a look at similar issues but I still wonder if it's 'react-enough' way. I'm concerned about |
@mdolbin That looks reasonable to me. |
Looks like this is up for grabs again as #5879 did not progress. |
I think I found a way to use |
Okay, trick question: how can I let the setState go through in My change, for instance, make fail https://github.com/facebook/react/blob/master/src/renderers/dom/server/__tests__/ReactServerRendering-test.js#L383 |
Answering my own question: maybe during initial mount, don't use (yet) the ReactNoopUpdateQueue. |
This commit fixes #5473: ReactDOMServer.renderToString: presence of onClick handler causes errors on async update This commit performs the following changes: - Adds a getUpdateQueue method to ReactServerRenderingTransaction, ReactReconcileTransaction, ReactNativeReconcileTransaction and ReactTestReconcileTransaction - Make the ReactCompositeComponent call this getUpdateQueue instead of using ReactUpdateQueue that was unwanted at certain moments on server - On ReactServerRenderingTransaction, dispatch ReactUpdateQueue's methods while rendering and warning methods afterwards. This is done through the new ReactServerUpdateQueue class - Added a series of tests that mimics the case presented in #5473 with setState, forceUpdate and replaceState - Add flow typechecking on concerned files
This commit fixes #5473: ReactDOMServer.renderToString: presence of onClick handler causes errors on async update This commit performs the following changes: - Adds a getUpdateQueue method to ReactServerRenderingTransaction, ReactReconcileTransaction, ReactNativeReconcileTransaction and ReactTestReconcileTransaction - Make the ReactCompositeComponent call this getUpdateQueue instead of using ReactUpdateQueue that was unwanted at certain moments on server - On ReactServerRenderingTransaction, dispatch ReactUpdateQueue's methods while rendering and warning methods afterwards. This is done through the new ReactServerUpdateQueue class - Added a series of tests that mimics the case presented in #5473 with setState, forceUpdate and replaceState - Add flow typechecking on concerned files (cherry picked from commit dbdddf1)
…ebook#7127) This commit fixes facebook#5473: ReactDOMServer.renderToString: presence of onClick handler causes errors on async update This commit performs the following changes: - Adds a getUpdateQueue method to ReactServerRenderingTransaction, ReactReconcileTransaction, ReactNativeReconcileTransaction and ReactTestReconcileTransaction - Make the ReactCompositeComponent call this getUpdateQueue instead of using ReactUpdateQueue that was unwanted at certain moments on server - On ReactServerRenderingTransaction, dispatch ReactUpdateQueue's methods while rendering and warning methods afterwards. This is done through the new ReactServerUpdateQueue class - Added a series of tests that mimics the case presented in facebook#5473 with setState, forceUpdate and replaceState - Add flow typechecking on concerned files
The code
produces errors:
But if I remove
onClick
handler the errors go away...See demo: http://codepen.io/dened/pen/YyByYr
The text was updated successfully, but these errors were encountered: