Improve documentation for `context`
See original GitHub issueWhen I proposed PR #576, I had some uncertainty about how Preact handles context
. Currently, the TypeScript declarations do provide for context?: any
in a few locations, so I just followed that convention. That said, it looks like Preact does not(?) support – or at least make use of – contextTypes
. I searched the documentation and the source to learn more about this, and so far have two issues (that I’ll file here as one issue):
-
I couldn’t find anything in the documentation about whether Preact actually does make use of
contextTypes
. I’m assuming that it doesn’t, since it doesn’t make use ofpropTypes
. My impression from the source is also that it does not. I think this should probably be documented somewhere (I’m happy to PR it; just want to check that I’m right and that I didn’t actually miss some documentation, first). -
Also, from looking at the source, it looks like Preact’s behavior with respect to
context
may not be exactly the same as React’s. Is this intended? As I understand it, in React, if a component does not define some context oncontextTypes
, then the component does not receive that context (see here, for example: https://github.com/facebook/react/blob/e452e3374135c116ef687a8bb3a5d277e3cde8fb/src/isomorphic/classic/__tests__/ReactContextValidator-test.js#L40). But if Preact doesn’t usecontextTypes
at all, then it presumably doesn’t have this behavior. Is that right, and is it intended? This might create some subtle issues with migrations from React to Preact, especially if (as in point 1 above) it isn’t documented anywhere, so I wanted to check.
Mostly, I’m looking for clarification on these things and seeing whether it would be helpful for me to try to PR some docs and/or some changes to the treatment of context
. Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Hi guys, I’m interested in getting started as a contributor and would love to take a shot at this.
Cool, and thanks for the quick response! That all sounds good. I’ll try to take a look at the docs as time permits.