properties屬性的意思 。
簡寫props
class ShoppingList extends React.Component {render() {return (<div className="shopping-list"><h1>Shopping List for {this.props.name}</h1><ul><li>Instagram</li><li>WhatsApp</li><li>Oculus</li></ul></div>);}}ShoppingList 組件類也叫組件類型 。
通過render方法,返回UI的視圖結構 。
ShoppingList 組件上圖渲染一些內置的 DOM 組件,也可以渲染自定義組件 。可以隨意組合 。
Failed to load plugin ‘flowtype‘ declared in ‘package.json ? eslint-config-react-app‘: Cannot find mreact出現這個錯誤就是node版本太低 。升高至16,以及16以上 。
react 父子通信
父
renderSquare(i) {return <Square value=https://www.baibaike.com/baike/{i} />;}子
{this.props.value}子組件在本組件的pros上取父組件傳過來的屬性 。
react在標簽上添加點擊事件 。
<button className="square" onClick={function(){alert('click')}}>{this.props.value}</button>State
組件私有
constructor(props) {super(props);this.state = {value: null,};}為什么要用super();
在 JavaScript class中,每次你定義其子類的構造函數時,都需要調用 super 方法 。因此,在所有含有構造函數的的 React 組件中,構造函數必須以 super(props) 開頭 。
this.setState改變組件內部state的值 。
onClick={() => this.setState({value: 'X'})}React Devtools可以在瀏覽器種查看react組件樹
需要的可以聯系作者要 React Devtools插件鏈接哦 。

文章插圖
【React入門知識 react什么意思】
- 懷孕知識大全 孕媽需牢記的注意事項
- 琥珀原石的鑒別方法是什么 蜜蠟琥珀原石鑒別知識大全
- 炒股入門知識大全_炒股票入門基礎知識
- 火災逃生知識_小學生發生火災時如何逃生
- 小學生普及知識 撥云見日是什么意思
- 溺水安全知識_關于防溺水安全的知識
- 游泳安全知識_游泳的安全衛生常識有哪些
- 電機銘牌知識 50hz是什么意思
- 消防知識題庫_消防工程師1級都考些啥,,什么筆試,電腦答題,,...
- 消防知識資料_安全知識資料
