绑定事件到状态
官方实现
安装
npm install react-link-state --save
使用示例
import React from 'react';import linkState from 'react-link-state'; export default MyForm extends React.Component { constructor(props) { super(props); this.state = { username: '', password: '', toggle: false }; } render() { console.log(this.state); return (
使用示例2
import linkState from 'react-link-state'class Demo extends Component { constructor(props) { super(props) this.state = { text: '' } } render() { const {text} = this.state return () }}
其它实现
安装
npm install --save linkstate
用法示例
import linkState from 'linkstate';class Foo extends Component { state = { text: '' }; render(props, state) { return ( ); }}
用法示例2
import linkState from 'linkstate'class Demo extends Component { constructor(props) { super(props) this.state = { text: '' } } render() { const {text} = this.state return () }}