React 数据流
React 原生数据流
class A extends React.Component {
constructor(props) {
super(props);
this.state = {
counter: 0,
};
}
render() {
const { title } = this.props;
const { counter } = this.state;
return (
<div>
<h2>{title}</h2>
Counter: {counter}
<button
onClick={() => {
this.setState({ counter: counter + 1 });
}}
>
+
</button>
</div>
);
}
}最后更新于