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