How does react use input to get the value of a decimal number?

JS Bin on jsbin.com

when the decimal point is deleted, it is impossible to enter the decimal point again. How to solve this problem?

can you do the following functions similar to vue

feels that react is really too troublesome to do this.

May.26,2021

+ event.target.value will drop the decimal point Filter, so you must remove the +

.
handleChange(event) {
    this.setState({value: event.target.value});
}

Please post the code directly. It's best not to give an outer chain like this.

Please use + expression

correctly
class HelloMessage extends React.Component {
  constructor(props) {
      super(props);
      this.state = {value: 1.1};
      this.handleChange = this.handleChange.bind(this);
  }
 
  handleChange(event) {
    this.setState({value: event.target.value});
  }
  render() {
    var value = this.state.value;
    return <div>
          <input type="text" value={this.state.value} onChange={this.handleChange} />
        <div>{this.state.value}</div>
        <div>{Number.isNaN(Number(this.state.value)) ? '' : ''}</div>
        
 
        </div>;
  }
}
ReactDOM.render(
  <HelloMessage />,
  document.getElementById('example')
);
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-1b3962a-2c194.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-1b3962a-2c194.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?