Designing the UI with stateful components and stateless functional components

While thinking about the component composition for a UI, design the root or a parent component as a stateful component that will contain child components or the composable components that only receive props and cannot manipulate state. All the state-changing actions using setState and life-cycle issues will be handled by the root or parent component.

In the applications developed for this book, there is a mixture of stateful higher-level components and smaller stateless components. For example, in the MERN Social application, the Profile component modifies the state for stateless child components, such as the FollowProfileButton and FollowGrid components. There ...

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.