If someone uses one of our compound components outside the React.createContext <ToggleContext.Provider />, they will experience a confusing error. We could provide a default value for our context, but in our situation that doesn't make sense. Instea…
Our current compound component implementation is great, but it's limited in that users cannot render the structure they need. Let's allow the user to have more flexibility by using React context to share the implicit state to our child <Toggle/> com…
Compound component gives more rendering control to the user. The functionality of the component stays intact while how it looks and the order of the children can be changed at will. We get this functionality by using the special React.Children.map fu…
In this lesson we'll learn about how you can use the prop-types module to validate a custom React component's props. You can write you own PropTypes vlidators like such: const PropTypes = { string(props, propName, componentName) { if(typeof props[pro…
Imaging you are building a Tabs component. If looks like: <Tabs> <TabList> <Tab> one </Tab> <Tab isDisabled> two </Tab> <Tab> three </Tab> </TabList> <TabPanels> <TabPanel> content one <…
SASS Bootstrap allows us to configure theme or branding variables that affect all components (e.g. Primary Color or Link Color). When we isolate our styles inside React components we lose the ability to theme them. To get round this we can put our th…
Have a similar post about Reac.memo. This blog is the take away from this post. To understand why to use 'React.useMemo' or 'React.memo' (basiclly lastest React version use 'useMemo'), is that if the function component or context create a new referen…