-
Notifications
You must be signed in to change notification settings - Fork 47.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
Inject the previous batching strategy when rendering to string #7930
Conversation
Before this change calling renderToStringImpl would inject ReactDefaultBatchingStrategy after completion, even if a custom batching strategy was injected before. This makes renderToStringImpl keep a reference to the batching strategy before it runs and reinject it afterwards.
@aweary Can you look at this? |
Seems fine to me. @ibash what's your use case for injecting a different batching strategy when server rendering? I can't say that's explicitly supported, but this change seems fine regardless. |
@aweary We are using server rendering in the browser - is there a better way to convert jsx to plain html? |
@ibash what kind of issues were you seeing when you weren't injecting a different batching strategy? And are you injecting a custom batching strategy or one from |
We are injecting a custom batching strategy, one that uses fastdom so that when we access the dom in other parts of our app it won't cause layout thrashing. There was no bug in react we are trying to avoid with the default batching strategy. |
Thanks for clarifying! It sounds like you're trying to integrate React within application that was built with a different library/platform, is that right? If so, that approach seems reasonable. Otherwise I'd be curious to know what kind of constraints you have that require you to render to HTML strings in the browser. |
That's about right, the constraint to render html strings in the browser with jsx isn't strict, but it's very convenient instead of introducing a different templating library. |
FWIW injecting custom batching strategies is not officially supported and will break in the future. |
@gaearon okay -- are there any more details on what changes are coming? |
This will take at least a few more months of work but internals are getting completely rewritten. We never officially supported relying on internals. You can learn more about this effort here: #6170 |
Hmm, I don’t think this PR is relevant anymore given that |
…ook#7930) Before this change calling renderToStringImpl would inject ReactDefaultBatchingStrategy after completion, even if a custom batching strategy was injected before. This makes renderToStringImpl keep a reference to the batching strategy before it runs and reinject it afterwards.
Before this change calling renderToStringImpl would inject ReactDefaultBatchingStrategy after completion, even if a custom batching strategy was injected before. This makes renderToStringImpl keep a reference to the batching strategy before it runs and reinjects it afterwards.