{"action":"created","issue":{"url":"https://api.github.com/repos/react-bootstrap/react-bootstrap/issues/1078","labels_url":"https://api.github.com/repos/react-bootstrap/react-bootstrap/issues/1078/labels{/name}","comments_url":"https://api.github.com/repos/react-bootstrap/react-bootstrap/issues/1078/comments","events_url":"https://api.github.com/repos/react-bootstrap/react-bootstrap/issues/1078/events","html_url":"https://github.com/react-bootstrap/react-bootstrap/issues/1078","id":97843758,"number":1078,"title":"Modal (and probably others) should use componentWillUnmount","user":{"login":"zerkms","id":302295,"avatar_url":"https://avatars.githubusercontent.com/u/302295?v=3","gravatar_id":"","url":"https://api.github.com/users/zerkms","html_url":"https://github.com/zerkms","followers_url":"https://api.github.com/users/zerkms/followers","following_url":"https://api.github.com/users/zerkms/following{/other_user}","gists_url":"https://api.github.com/users/zerkms/gists{/gist_id}","starred_url":"https://api.github.com/users/zerkms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zerkms/subscriptions","organizations_url":"https://api.github.com/users/zerkms/orgs","repos_url":"https://api.github.com/users/zerkms/repos","events_url":"https://api.github.com/users/zerkms/events{/privacy}","received_events_url":"https://api.github.com/users/zerkms/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-07-29T02:27:55Z","updated_at":"2015-07-29T11:18:21Z","closed_at":null,"body":"Currently all listeners and some other routines are handled in `onHide` method:\r\n\r\n      componentDidUpdate(prevProps) {\r\n        let { animation } = this.props;\r\n\r\n        if ( prevProps.show && !this.props.show && !animation) {\r\n          //otherwise handleHidden will call this.\r\n          this.onHide();\r\n        }\r\n        else if ( !prevProps.show && this.props.show ) {\r\n          this.onShow();\r\n        }\r\n      }\r\n\r\n\r\nhttps://github.com/react-bootstrap/react-bootstrap/blob/master/src/Modal.js#L268\r\n\r\nSo the only way `this.onHide` is invoked is when it was about to update.\r\n\r\nIf you have a layout like:\r\n\r\n    <MyComponent>\r\n        <Modal ... />\r\n    </MyComponent>\r\n\r\nand at some moment I remove the `MyComponent` from the page then the `Modal` does not have chance to unbind its listeners and clean up mess after itself.\r\n\r\nThis might be solved if `this.onHide()` is invoked in `componentWillUnmount` additionally.\r\n\r\nAs a workaround in `MyComponent` I used a dirty\r\n\r\n    componentWillUnmount() {\r\n        this.refs.modal.onHide();\r\n    }\r\n\r\nand assigned a `ref=\"modal\"` to the corresponding `Modal` element."},"comment":{"url":"https://api.github.com/repos/react-bootstrap/react-bootstrap/issues/comments/125922125","html_url":"https://github.com/react-bootstrap/react-bootstrap/issues/1078#issuecomment-125922125","issue_url":"https://api.github.com/repos/react-bootstrap/react-bootstrap/issues/1078","id":125922125,"user":{"login":"zerkms","id":302295,"avatar_url":"https://avatars.githubusercontent.com/u/302295?v=3","gravatar_id":"","url":"https://api.github.com/users/zerkms","html_url":"https://github.com/zerkms","followers_url":"https://api.github.com/users/zerkms/followers","following_url":"https://api.github.com/users/zerkms/following{/other_user}","gists_url":"https://api.github.com/users/zerkms/gists{/gist_id}","starred_url":"https://api.github.com/users/zerkms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zerkms/subscriptions","organizations_url":"https://api.github.com/users/zerkms/orgs","repos_url":"https://api.github.com/users/zerkms/repos","events_url":"https://api.github.com/users/zerkms/events{/privacy}","received_events_url":"https://api.github.com/users/zerkms/received_events","type":"User","site_admin":false},"created_at":"2015-07-29T11:18:21Z","updated_at":"2015-07-29T11:18:21Z","body":"@jquense from my perspective the callbacks handling should be in a single place, not spread all over the code. Currently there is no easy way to tell when and why `this.props.onHide` will be called"}}