Skip to Content
Beginning React
book

Beginning React

by Andrea Chiarelli
July 2018
Beginner
96 pages
2h 8m
English
Packt Publishing
Content preview from Beginning React

Managing Styles

Perhaps you have noticed that we have an import statement concerning a CSS file in the App component module:

import React, { Component } from 'react';import './App.css';import Catalog from './Catalog';

This may seem a bit strange, since import statements should only work for JavaScript code. However, thanks to the development environment provided by create-react-app, we can use the same syntax, even for CSS files. This allows us to use the classes and other CSS definitions defined in App.css in our component, keeping component-specific styles close to the component definition itself. For example, if we want our Catalog component to have the title in red, we can proceed as shown next.

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

Test-Driven React

Test-Driven React

Trevor Burnham
Pro React 16

Pro React 16

Adam Freeman

Publisher Resources

ISBN: 9781789530520Supplemental Content