Sometimes I have to pragmatically open or close a modal without the help of trigger prop. This is just an example:
````
class Example extends React.Component {
state = { open: false }
constructor(props){
super(props);
this._toggle = this._toggle.bind(this);
}
render() {
const { open } = this.state
return (
open?
onOpen={this.open}
onClose={this._toggle}
size='small'>
dgfdgfdgfdgf
:
)
}
_toggle(){
this.setState({open:!this.state.open})
}
}
````
Before 0.75, I can do that without a warning, as shown in the 0.74 example.
However, since 0.75, I'm getting this warning when onClose is fired:
Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op.
Is it a bug or do I really need to use a trigger element from now on?
0.75.1
Looks like bug, the investigation and contributions are welcome.
@layershifter
I suspect in 0.75, the new argument {scrolling:false} for trySetState in Modal.js is causing the error in /lib/AutoControlledComponent.js
````
handleClose = (e) => {
debug('close()')
const { onClose } = this.props
if (onClose) onClose(e, this.props)
this.trySetState({ open: false }, { scrolling: false })
}
```
The error is thrown whentrySetStatein/lib/AutoControlledComponent.jsis updating the new state{ scrolling: false }`
AutoControlledComponent.js
this.trySetState = function (maybeState, state) {
/...../
if (Object.keys(newState).length > 0) _this3.setState(newState); <<
}
@stonecold123 Thanks :+1: Seems, you're right. I will check this in evening and will make PR
Most helpful comment
@stonecold123 Thanks :+1: Seems, you're right. I will check this in evening and will make PR