Refactoring component structures
We have a monolithic feature component—now what? Let's make it better.
In this section, you'll learn how to take the feature component that we just implemented in the preceding section and split it into more maintainable components. We'll start with the JSX, as this is probably the best refactor starting point. Then, we'll implement new components for the feature.
Finally, we'll make these new components functional, instead of class-based.
Start with the JSX
The JSX of any monolithic component is the best starting point for figuring out how to refactor it into smaller components. Let's visualize the structure of the component that we're currently refactoring:
The top part of the JSX is form controls, so this could easily become its own component:
<header> <h1>Articles</h1> <input placeholder="Title" value={title} onChange={this.onChangeTitle} /> <input placeholder...