clear form inside modal after close reactjs
If the data from the inputs is in your component you can try something like this : In closeModal you can set the initial state of the component
const initialState = { name: null, inStock: null, price: null, type:null }
closeModal = () => {
this.setState({
...initialState,
modalIsOpen: false
});
}
But if the stat of the inputs is coming from the Parent you need a new method to reset the data of the parent component that cpuld be added as a callback in the same method.
const initialState = { name: null, inStock: null, price: null, type:null }
closeModal = () => {
this.setState({
modalIsOpen: false
}, () => {
this.props.resetInputData();
});
}
Also in JavaScript:
- How can I check whether a variable is defined in Node Js
- javascript regex One or more occurrences of the pattern
- javascript enumerate
- chat application in react js
- json url data is not showing in console using jquery
- jquery on click return link url
- generate random character in javascript
- clear timeout js
- get first element by class name jquery
- three.js create sphere
- how to get user ip address in javascript
- find an object from array of objects javascript
- javascript set query parameter
- d3 v6
- DECIMAL TO BINARY CONVERSION javascript
- sort data according to date in js
- javascript require
- what is jquery
- ionic g service services/auth ionic g service services/authGuard npm i @ionic/storage npm i @auth0/angular-jwt ionic cordova plugin add cordova-sqlite-storage
- document.queryselector picks first or last
- drag n drop file upload react
- js get current seconds
- string interpolation
- Updating Object Properties