Export component

Finally, in the last line of code in the component file, we will export the component with the defined styles passed in using withStyles from Material-UI. Using withStyles like this creates a Higher-order component (HOC) that has access to the defined style objects as props.

mern-skeleton/client/core/Home.js:

export default withStyles(styles)(Home)

The exported component can now be used for composition within other components, as we did with this Home component in a route in the MainRouter component discussed earlier.

The other view components to be implemented in our MERN applications will adhere to the same structure. In the rest of the book, we will focus mainly on the component definition, highlighting the unique aspects ...

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.