I am trying to update a state based on my props in my react Class based component but i am getting an error
TypeError: Cannot assign to read only property 'statusKnown' of object '#'
here is the code below
componentDidMount(){
this.calClass()
}
calClass = () => {
console.log(this.props.statusKnown, this.state.active);
if (this.props.statusKnown == "deactive") this.setState({ active: false });
else if ((this.props.statusKnown = "active")) this.setState({ active: true });
};
and then in parent component
<Button item={item} categoryID={categoryID} statusKnown={status}/>;
If react doesn't allow this thing, then what is the possible solution for this ?