*Brian *Sultana *Nathaniel
-
What situations would be good to use context? Context is designed to share data that can be considered “global” for a tree of React components, such as the current authenticated user, theme, or preferred language. Deeply nested components that need global information.
-
If you need to pass a prop down 1 or 2 levels, is context necessary? No, context is only necessary when working through many levels. If you only want to avoid passing some props through many levels, component composition is often a simpler solution than context. Common examples where using context might be simpler than the alternatives include managing the current locale, theme, or a data cache
-
Can you pass a component instance as a prop to avoid the need for context? Yes, by setting a component to a variable and passing that variable as a prop you can avoid using context.
const content = <Feed user={user} />;
-
Can you write your own components that accept render props? Yes, any prop that is a function that a component uses to know what to render is technically a “render prop”. There are no limitations on what you can pass as props in React.