React Intro
Source: React新手指南
1 L09
1.1 Each component must return
a root
element
1.1.1 usa a <div></div>
1.1.2 use an empty element <></>
…which is the same as using <Fragment>
1.2 Expression
Value of a variable can called in both the 1) contents, and 2) properties of an element as an
expression
, i.e., enclosed in{}
expression
carries dynamicdata
, especially those passing to the component from outside.
MyComp01.jsx
- 1
- used in content
- 2
- used in property
- 3
- conditional expression used in content
1.3 Naming conventions of properties
class
->className
for
->htmlFor
style
must be specified asobjects
, as shown below:
1.4 render by expression
1.5 render by an array
Note
A unique key
must be provided to each element in the array.