I keep getting this error in React Native and I have not found a solution yet after a few hours.
Warning: Can't call setState on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to
this.state
directly or define astate = {};
class property with the desired state in the myEnabled component.
constructor(props){
super(props);
this.state = { enabled: true };
this.setEnabled = this.setEnabled.bind(this);
}
setEnabled(value){
this.setState({ enabled: value });
}
getState(){
return this.state.enabled;
}