React入門知識 react什么意思

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什么意思

文章插圖
【React入門知識 react什么意思】