Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. What situations would be good to use context?
  2. Context would be used when one needs to pass down data that needs to be access by several deeply nested components. It's a good way to solve the problem of prop-drilling, where props are passed down through many components in order to reach a great-grandchild component.
  3.  
  4. If you need to pass a prop down 1 or 2 levels, is context necessary?
  5. No. You should start thinking about context when the nested component is 5-6 components deeps. Context should be avoided if you can, because it makes component reuse difficult.
  6.  
  7. Can you pass a component instance as a prop to avoid the need for context?
  8. Yes you can, it's called component composition.
  9.  
  10. Can you write your own components that accept render props?
  11. Yes, this can be done if the child prop needs to communicate with the parent component before rendering.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement