Topic: MDBFileInput State Change
sedonawebservices pro asked 5 years ago
I want to update the local state using MDBFileInput. How might I accomplish this? It doesn't seem like there is an "onChange" or similar method available.
I also couldn't find any documentation for any props on these components, which would be helpful.
Jonathan
Anna Morawska staff answered 5 years ago
Hi Jonathan,
Every page of documentation has Overview section and API section. In the second one, you can find every property and method associated with the component. Use the top Tabs to navigate.
Reffering to the issue with MDBFileInput component - you have to use getValue property as shown bellow:
import React from 'react';
import { MDBFileInput } from "mdbreact";
class App extends React.Component {
state = {
file: null
};
fileChangeHandler = files => {
this.setState({file: files[0] } , () => console.log(this.state))
}
render() {
return (
<>
<MDBFileInput getValue={this.fileChangeHandler} />
</>
);
}
}
export default App;
Best,
Ania
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Pro
- Premium support: No
- Technology: MDB React
- MDB Version: 4.8.4
- Device: Desktop
- Browser: Chrome
- OS: OS X
- Provided sample code: No
- Provided link: No