How to fix Warning: Can't call setState (or forceUpdate) 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 a `state = {};` class property with the desired state in the component. in React | DevErrors