Skip to Main Content
React Design Patterns and Best Practices - Second Edition
book

React Design Patterns and Best Practices - Second Edition

by Carlos Santana Roldán
March 2019
Intermediate to advanced content levelIntermediate to advanced
350 pages
7h 28m
English
Packt Publishing
Content preview from React Design Patterns and Best Practices - Second Edition

Locally scoped CSS

Now, it is time to create our app, which will consist of a Simple button, of the same sort we used in previous examples. We will use it to show all the features of the CSS modules.

Let's create an index.js file, which is the entry we specified in the webpack configuration, and let's import React and ReactDOM as well:

  import React from 'react';  import { render } from 'react-dom';

We can then create a Simple button. As usual, we are going to start with a nonstyled button, and we will add the styles step by step:

  const Button = () => <button>Click me!</button>;

Finally, we can render the button into the DOM:

  render(<Button />, document.body);

Please note that rendering a React component into the body is bad practice, but ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

React 17 Design Patterns and Best Practices - Third Edition

React 17 Design Patterns and Best Practices - Third Edition

Carlos Santana Roldán

Publisher Resources

ISBN: 9781789530179Supplemental Content