Topic: Input component value property does not work with null string
rmedrano23
pro asked 7 years ago
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { Button, Input} from 'mdbreact'
class App extends Component {
constructor (props) {
super(props)
this.state= {
valor:'Hola'
}
}
clearField= () => {
console.log('limpiarCampo')
// I expect this line to clear the input field but is doesn't...
this.setState({valor:''})
}
answer= () => {
console.log('contestar')
this.setState({valor:'como vas?'})
}
setValue= (valor) => {
console.log('asignarValor')
this.setState({valor:valor})
}
render() {
return (
<divclassName="App">
<Inputtype='text'value={this.state.valor}onChange={e=>this.setValue(e.target.value)}/>
<ButtononClick={this.clearField}>
Limpiar
</Button>
<ButtononClick={this.answer}>
Contestar
</Button>
</div>
);
}
}
export default App;
Jakub Mandra
staff premium answered 7 years ago
rmedrano23 pro commented 7 years ago
Thanks! I will wait for this release on Monday ... I was about to abandon the material version and use the regular one ... :-)rmedrano23 pro commented 7 years ago
Any news about this bug?Jakub Mandra staff premium commented 7 years ago
Should be good now, please upgrade your mdb package to the newest (4.8.0) version :)rmedrano23 pro commented 7 years ago
yeahhh it's working correctly now. Tnx a lot.Jakub Mandra staff premium commented 7 years ago
That's great :)FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: No
- Technology: MDB React
- MDB Version: 4.7.0
- Device: Mac
- Browser: Chrome
- OS: Max OS High Sierra 10.13.6
- Provided sample code: No
- Provided link: No