-
Notifications
You must be signed in to change notification settings - Fork 34
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
Support React v16.3 context API #22
Comments
Ok, so it turns out my issue is not with function as children components. With a simple test eventually const TestComponent = ({ children }) => children('foobar')
const tree = <TestComponent>{message => <p>{message}</p>}</TestComponent>
reactTreeWalker(
tree,
element => {
console.log(element)
return true
}
) What does not work is const { Provider, Consumer } = React.createContext()
const tree = (
<Provider value={{ message: 'foobar' }}>
<Consumer>{({ message }) => <p>{message}</p>}</Consumer>
</Provider>
)
reactTreeWalker(
tree,
element => {
console.log(element)
return true
}
) The deepest node is logged as |
Consumer
components
Looks like this is ready to be worked on 😀 @jaydenseric are you happy with running with this? |
@ctrlplusb thanks, but I've already worked it out in |
Consumer
components
@ctrlplusb Can I come back to the original question at the start of the thread by @jaydenseric:
What is the expected behavior here? |
@ctrlplusb relevent discussion: facebook/react#12501 (comment) |
Has anyone taken this up? Would really like to convert a project using tree-walker to use new React context. |
@lemonmade not as of yet. Would you be open to giving it a shot via a PR? |
@ctrlplusb I tried something, maybe the PR can serve as a starting point? |
Just merged @dan-lee's and published work on this. 🎉 |
Function as children components are becoming very popular. In React v16.3 the new context API uses this pattern.
How do you walk into the children functions, so you can keep recursing the tree and visit deeper components?
For context, I am attempting to SSR
Query
components ingraphql-react
.The text was updated successfully, but these errors were encountered: