November 2018
Beginner
502 pages
10h 22m
English
React context allows state to be shared between components. It works really well with compound components. We are going to use it in our Tabs and Tab components to share state between them:
interface ITabsContext { activeName?: string; handleTabClick?: (name: string) => void;}
So, our context will contain the active tab name as well as a reference to a tab click handler. These are the two bits of state that need to be shared between the components.
const TabsContext = React.createContext<ITabsContext>({}); ...Read now
Unlock full access