How to use two-way binding correctly under react+typescript

for example, if you bind an input value in both directions, is it too low-end to bind only through the onChange event?

Jan.28,2022

typescript binds as native JS binds. Typescript just changes js syntax and does not change react


react is not the v-model syntax sugar of vue, without vue. You need your own onchange to trigger the change of state, and then input value goes to get the state, that is, the controlled component

.
class Demo1 extends Component {
    constructor(props) {
        super(props);
        this.state = {
            value: props.value
        }
    }

    handleChange(e) {
        this.setState({
            value: e.target.value
        })
    }

    render() {
        return (
            <input value={this.state.value} onChange={e => this.handleChange(e)}/>
        )
    }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3d2e2-34722.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3d2e2-34722.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?