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

Mark render-to-str deprecated, show how to do it yourself #547

Merged
merged 1 commit into from
Sep 24, 2023

Conversation

holyjak
Copy link
Collaborator

@holyjak holyjak commented Sep 23, 2023

Use proper require of react-dom/server and invoke its renderToString, instead of accessing the global js/ReactDOMServer, which might not be available.

I had troubles making sure that js/ReactDOMServer and thus couldn't render to a string. With this change, it works fine.

BEWARE: I don't know whether the use of js/ReactDOMServer is a left-over from old times, or whether it is intentional, e.g. to make sure that we do not require react-dom/server if not needed. So I don't know whether this change is desirable or not.

@awkay
Copy link
Member

awkay commented Sep 23, 2023

I think I had some notion that I wanted to make this optional...to avoid code bloat. shadow will make that an extern, and will include it in every build (even if you don't use it. no dead code elimination on js libs). Doing the way I did it means you won't get react dom server in your advanced builds unless you require it elsewhere.

so, while what you have is cleaner, I'd rather see a deprecated tag on the function with a recommendation that you just use require and directly reference it yourself.

@holyjak holyjak changed the title From js/ReactDOMServer -> react-dom/server's renderToString Mark render-to-str deprecated, show how to do it yourself Sep 24, 2023
@holyjak
Copy link
Collaborator Author

holyjak commented Sep 24, 2023

Done!

@awkay awkay merged commit 3d98f70 into main Sep 24, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants