-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[docs] Warn about using withRoot HOC more than one time per page #12692
Conversation
e13697d
to
c3d5ddc
Compare
examples/gatsby/README.md
Outdated
## Providing the theme | ||
|
||
To propagate the theme to a component tree use the `src/withRoot.js` HOC. | ||
You should wrap **only** your top-level components with this HOC otherwise you risk re-rendering your React tree multiple times and styling issues during the build phase. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"and causing styling issues"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I provided some screenshots on the #12649 . dont know how to describe best the issues in the screenshots.
@oorestisime Does it mean we can't use |
@oliviertassinari yes we can. there are two possibilities (i think)
|
@oorestisime Oh ok, so people shouldn't mount two |
Yes exactly, and that was the source of the problems i was experiencing. I think all the repos i saw around using material-ui and gatsby were using withRoot with the problematic way i was using it and that's why i thought of clearing this out in the docs. Let me know if i need to rephrase or anything |
@oorestisime Ok thanks. I think that we should be updating the Next.js README.md with the same message. It the same architecture. |
Oh no, my bad, we have recently updated the Next.js example to use |
281ceb0
to
7151254
Compare
@mbrookes I have tried a different wording. Feel free to modify it. |
…#12692) * [docs] Improve gatsby example giving more details on the HOC component
Based on discussions here #12649 and gatsbyjs/gatsby#2116 i think the gatsby example deserves a small warning on the usage of the withRoot HOC