Skip to content
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

Merged
merged 1 commit into from
Oct 11, 2016
Merged

Inject the previous batching strategy when rendering to string #7930

merged 1 commit into from
Oct 11, 2016

Conversation

ibash
Copy link
Contributor

@ibash ibash commented Oct 10, 2016

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.

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.
@gaearon
Copy link
Collaborator

gaearon commented Oct 11, 2016

@aweary Can you look at this?

@aweary
Copy link
Contributor

aweary commented Oct 11, 2016

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.

@ibash
Copy link
Contributor Author

ibash commented Oct 11, 2016

@aweary We are using server rendering in the browser - is there a better way to convert jsx to plain html?

@aweary
Copy link
Contributor

aweary commented Oct 11, 2016

@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 lib, like ReactServerBatchingStrategy?

@ibash
Copy link
Contributor Author

ibash commented Oct 11, 2016

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.

@aweary
Copy link
Contributor

aweary commented Oct 11, 2016

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.

@ibash
Copy link
Contributor Author

ibash commented Oct 11, 2016

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.

@aweary aweary merged commit b77a96e into facebook:master Oct 11, 2016
@gaearon
Copy link
Collaborator

gaearon commented Oct 11, 2016

FWIW injecting custom batching strategies is not officially supported and will break in the future.

@ibash
Copy link
Contributor Author

ibash commented Oct 11, 2016

@gaearon okay -- are there any more details on what changes are coming?

@gaearon
Copy link
Collaborator

gaearon commented Oct 11, 2016

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
https://github.com/acdlite/react-fiber-architecture
https://youtube.com/watch?v=aV1271hd9ew

@gaearon
Copy link
Collaborator

gaearon commented Jan 6, 2017

Hmm, I don’t think this PR is relevant anymore given that react-dom and react-dom/server don't share state now.

acusti pushed a commit to brandcast/react that referenced this pull request Mar 15, 2017
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants