Context is broken with react-tree-walker
See original GitHub issueCreating this issue so that we have one place to discuss potential solutions.
I recently added react-tree-walker
to this package so that we can traverse React component trees to determine the exact namespaces required to render that tree correctly. This allows us to do SSR in the most efficient way possible.
However, it seems that there are several context-related issues with react-tree-walker
:
- Context is poorly supported in general.
- Users are passing custom context, which will end up being missed by the shallow render inside the
app-with-translation
HOC.
Instead of going down this road, I would really prefer if we can come up with a different way to do tree traversal that does not depend upon context. All we need to do is traverse a tree, checking for props.ns
. If props.ns
exists, we need to add it to an array. That’s it.
Does anyone have any good ideas?
Otherwise, we’ll probably need to revert to sending down all namespaces to the client. This is not ideal, especially for (very) large apps.
Issue Analytics
- State:
- Created 5 years ago
- Comments:27 (25 by maintainers)
Thanks @isaachinman for this direction. I love this very much, as it’s very easy to integrate i18n to any existing Next.JS project without breaking anything. Because it’s just
getInitialProps
after all, no magic hidden for user to debug.7f7fc63