The problem I encountered is to enter text for the first time, then click "Add" and the input text box will be cleared. However, when I start typing again, the input text will not let me enter the text separately from the first letter. I'm not sure why he does it.
var FormTextBox = React.createClass({ handleOnBlur: function (e) { this.props.onBlur(e.target.value); }, render: function () { return ( <input value={this.props.value} key={this.props.fid} type="text" onBlur={this.handleOnBlur} /> ) } }); var TestFormTextBox = React.createClass({ getInitialState: function (e) { return { value: '' } }, handleOnAdd: function (e) { this.setState({ value: '' }); }, handleTextInfo: function (value) { this.setState({ value: value }); }, render: function () { return ( <div> <table> <tbody> <tr> <td>Details</td> <td></td> </tr> <tr> <td><FormTextBox value={this.state.value} fid={1} onBlur={this.handleTextInfo} /></td> <td><button onClick={this.handleOnAdd}>Add</button></td> </tr> </tbody> </table> </div> ) } });
source share