Created
September 13, 2019 02:45
-
-
Save Thersis94/d3c73d7f451617392ab96f93d083a0a8 to your computer and use it in GitHub Desktop.
Thinkful Checkpoint 15 React Context Questions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. What situations would be good to use context? | |
A good situation to use context in would be if you need to drill through multiple layers of components, | |
or if you have a lot of components that all need to access STATE. | |
2. If you need to pass a prop down 1 or 2 levels, is context necessary? | |
No the use of context is not always necessary. Sometimes you are better of just passing props if you only need to pass that | |
information through one or two components. It can also make component reuse more difficult if used in inapropriate situations. | |
3. Can you pass a component instance as a prop to avoid the need for context? | |
Yes! You can simply pass a component instance down through your components instead of using context. This can save you a headache | |
when you need to pass more props. | |
4. Can you write your own components that accept render props? | |
Yes, you can use use render props if the child needs to communicate with the parent before rendering. However, sometimes data needs to | |
ne accessinle by many components in the tree, and at different nesting levels. COntext lets you "broadcast" such data, and changes to it, | |
to all components below. Common examples where using context might be simpler than the alternatives include managing the current locale, thene, | |
or a data cache. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment