Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HyunwooMoon-developer/609c3dc7007016b443866ef570dba636 to your computer and use it in GitHub Desktop.
Save HyunwooMoon-developer/609c3dc7007016b443866ef570dba636 to your computer and use it in GitHub Desktop.
Creating and Reading Context
Q1. What situations would be good to use context?
A: we can avoid passing props through intermediate elements , pass down props to deeply nested components.
Q2. If you need to pass a prop down 1 or 2 levels, is context necessary?
A: Context provides a way to share values like these between components without having to explicitly pass a prop through every level of the tree.
Context is primarily used when some data needs to be accessible by many components at different nesting levels. Apply it sparingly because it makes component reuse more difficult.
Q3. Can you pass a component instance as a prop to avoid the need for context?
A: Yes, We can pass a component with prop down.
Q4. Can you write your own components that accept render props?
A: Take it even further with render props if the child needs to communicate with the parent before rendering.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment