This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please be sure to read the contributor's guide to the GitHub package before submitting any pull requests.
Requirements
Description of the Change
My goal here is to investigate using React's
useContext
hook to address our prop drilling problem (#1437). The major reason whyuseContext
is suitable as a potential solution here is that it makes consuming multiple context objects within a single component ergonomic:Doing this with traditional contexts meant a layer of render prop per context:
My plan is to introduce a context package for each major grouping of commonly drilled props, along with utility methods and custom hooks to ease common access patterns.
Screenshot/Gif
N/A
Alternate Designs
See #2027 for my pre-hooks take on the problem.
Benefits
Improved maintainability by not having to pass large sets of Atom-related props through deep component hierarchies.
Possible Drawbacks
useContext
only works within functional components, so this basically involves gradually re-writing everything.The Enzyme shallow renderer has issues with functional components and hooks, so this will need to wait until those are fixed and included in an Enzyme release: enzymejs/enzyme#2176, enzymejs/enzyme#2086.
Applicable Issues
#1437
Metrics
N/A
Tests
N/A
Documentation
N/A
Release Notes
N/A
User Experience Research (Optional)
N/A