Semantic-ui-react: Modal: on close warning in 0.75

Created on 22 Oct 2017  路  3Comments  路  Source: Semantic-Org/Semantic-UI-React

Steps

0.75.1 example
0.74 example

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?
open={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.

Actual Result

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?

Version

0.75.1

bug

Most helpful comment

@stonecold123 Thanks :+1: Seems, you're right. I will check this in evening and will make PR

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hankthewhale picture hankthewhale  路  3Comments

GautierT picture GautierT  路  3Comments

jayphelps picture jayphelps  路  3Comments

levithomason picture levithomason  路  3Comments

KevinGorjan picture KevinGorjan  路  3Comments