question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve documentation for `context`

See original GitHub issue

When 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):

  1. 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 of propTypes. 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).

  2. 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 on contextTypes, 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 use contextTypes 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:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
paulseverecommented, Apr 10, 2017

Hi guys, I’m interested in getting started as a contributor and would love to take a shot at this.

2reactions
jmrogcommented, Mar 2, 2017

Cool, and thanks for the quick response! That all sounds good. I’ll try to take a look at the docs as time permits.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strategies for Improving Documentation
This guide has been written from the risk management perspective with the aim of enhancing team communication and continuity of care through improved...
Read more >
Best Practices that Improve the Quality of Documentation
Simplify technical documents and improve readability. · Eliminate words, sentences or phrases that can confuse readers.
Read more >
5 tips to improve clinical documentation | NueMD Industry News
5 tips to improve clinical documentation · 1. Define professional standards · 2. Expand education · 3. Create peer-to-peer support systems · 4....
Read more >
Strategies for improving physician documentation in ... - NCBI
Background. Physician chart documentation can facilitate patient care decisions, reduce treatment errors, and inform health system planning and resource ...
Read more >
Write it down and save it — tips for good documentation
Documentation is critical to creative collaboration. Even informal notes are useful. Don't be afraid. And don't wait — make it part of your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found