Getting Started

A 1-post collection

Using React's new context API

Why context? A component tree can quickly grow. The root component has many children, the children have many children and so on. What if you want to pass information that is considered global to a tree or subtree of components? For example what language these components should use. Or what the username is. You could use props of course, but it seems unnessary to pass on the same information over and over again to each component. This is where the context comes in. Pre context In this example from the React website no context is used. The theme with value dark is passed with a prop to the child toolbar component which passes it on to it's child ThemedButton also...