- React Design Patterns and Best Practices(Second Edition)
- Carlos Santana Roldán
- 74字
- 2021-06-24 15:43:38
Style
A pretty significant difference is the way the style attribute works. We will look at how to use it in more detail in Chapter 7, Make Your Components Look Beautiful, but now we will focus on the way it works.
The style attribute does not accept a CSS string as the HTML parallel does, but it expects a JavaScript object where the style names are camelCased:
<div style={{ backgroundColor: 'red' }} />