Summary

In this chapter, we learned about container components and how they can be used to manage state and what presentational components need to do. Presentational components can then focus on what they need to look like. This allows presentational components to be more easily reused in multiple places and unit-tested.

We learned that compound components are components that rely on each other. Declaring compound children as static members on the parent class make it clear to a consumer that the components should be used together. React context is a convenient way for compound components to share their state.

We learned about the special children prop that can be used to access and render a component's children. We then learned that we can create our own render props to give consumers great flexibility for custom-rendering sections of a component.

In the last section, we learned about higher-order components and how they can be used to implement common enhancements to components. We already consumed the React Router higher-order component when gaining access to a paths parameters earlier in the book.

In the next chapter, we'll learn how we create forms in React. Towards the end of the next chapter, we'll use some of these patterns that we have learned in this chapter in order to deal with forms in a generic way.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.226.120