-
-
Notifications
You must be signed in to change notification settings - Fork 924
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
Use context instead of injecting props to Document's children #124
Comments
That is a freaking awesome idea! I have a hard time believing I did not think of that up until now. I'll start experimenting right away! |
If you want to have a look, go to feature/use-context branch. But to implement such a big change, I need to write tons of test beforehand. I plan to do that, but I have issues with binary files in Jest testing environment - I'll keep you updated for sure. |
@wojtekmaj I understand benefits from @Treora but what about official documentation which says
|
Hmmm... I am aware of this, but I think that may be just the thing that would solve our problems. Anyway, I'm not planning to even release an alpha context-based until I have VERY good set of tests. I'm not nearly done with writing unit tests so far. Once I have an excellent test suite I may consider using context. So far, I only think it's a neat idea and I know that Proof of Concept works as expected. |
Coming back with a small update: |
Currently the
<Document>
component clones all its children and adds some props so that each<Page>
can read these props. The approach has a few downsides however:<Page>
s gives trouble. For example, you may want a tree of the shape<Document><Button>Next page</Button><Page /></Document>
. The button will also get all the extra props injected, which might break it or cause it to complain. The apparent solution of pulling the<Button>
out of the<Document>
may not be desirable, as e.g. the button would also be rendered when the document is still loading.<Page>
inside another element (unless that passes down all props). E.g.<Document><div><Page /></div></Document>
would fail.To overcome these issues, would it perhaps be a good idea to stop injecting props, and instead use React's Context to couple the
Document
andPage
components?The text was updated successfully, but these errors were encountered: