I have a React class component that allows some details to be hidden or shown when a button is clicked in the app.
I intialised the state to be as below;
class Admin extends React.Component {
constructor(props){
super(props)
this.state = {
show: false,
}
}
and then updated the state property like below;
const handleDetails = (props) => {
this.setState(prevState => ({
show: !prevState.show}))
}
The project runs, but when the handleDetails function is called, it returns an error of
Cannot read property 'setState' of undefined