mdbootstrap / mdb-react-ui-kit

React 18 & Bootstrap 5 & Material Design 2.0 UI KIT
https://mdbootstrap.com/docs/b5/react/
Other
1.41k stars 264 forks source link

Input not updatable #35

Closed wayne1203 closed 6 years ago

wayne1203 commented 6 years ago

I'm using 4.3.0 of mdbreact

I would like to clear the input value using state but not work.

Here is my code

this.setState({
    heading: ""
});

<Input
    containerClass="col-12 input nopadding"
    hint="Heading"
    maxLength="20"
    value={this.state.heading}
    onChange={(value) => this.setState({heading: value.target.value})}
/>

It's work fine if I use HTML code, maybe componentWillReceiveProps problem?

<div class="md-form col-12 input nopadding">
    <input maxlength="20" type="text" class="form-control" placeholder="Heading"
        maxLength="20"
        value={this.state.heading}
        onChange={(value) => this.setState({heading: value.target.value})}/>
</div>
smolenski-mikolaj commented 6 years ago

Hi, the problem should be fixed with the next version of React (next week).

The following code might be helpful:

`

` ` constructor(props) { super(props); this.state = {value: 'John Doe'}; this.handleChange = this.handleChange.bind(this); } handleChange(event) { this.setState({value: event.target.value}); }` Regards