React Design Patterns and Best Practices(Second Edition)
上QQ阅读APP看书,第一时间看更新

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 7Make 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' }} />