diff --git a/package.json b/package.json index 5fd7dcc..b69f8d3 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "serve": "webpack-dev-server --host 0.0.0.0 --hot --inline --history-api-fallback", "start": "npm-run-all --parallel karma:dev serve", "karma:once": "karma start --single-run", - "karma:dev": "karma start --browsers Chrome", + "karma:dev": "karma start --browsers Chromium", "babel": "babel src -d lib", "build": "npm-run-all clean babel", "lint": "eslint '*.js' '{src,test}/**/*.js*'", diff --git a/src/Content.jsx b/src/Content.jsx index 2b4262b..bc17267 100644 --- a/src/Content.jsx +++ b/src/Content.jsx @@ -5,7 +5,8 @@ export default class Content extends Component { static propTypes = { children: PropTypes.element.isRequired, contentDidMount: PropTypes.func.isRequired, - contentDidUpdate: PropTypes.func.isRequired + contentDidUpdate: PropTypes.func.isRequired, + contentWillUnmount: PropTypes.func.isRequired }; componentDidMount() { @@ -16,6 +17,10 @@ export default class Content extends Component { this.props.contentDidUpdate(); } + componentWillUnmount() { + this.props.contentWillUnmount(); + } + render() { return Children.only(this.props.children); } diff --git a/src/Frame.jsx b/src/Frame.jsx index 767362a..9498fad 100644 --- a/src/Frame.jsx +++ b/src/Frame.jsx @@ -16,6 +16,7 @@ export class Frame extends Component { mountTarget: PropTypes.string, contentDidMount: PropTypes.func, contentDidUpdate: PropTypes.func, + contentWillUnmount: PropTypes.func, children: PropTypes.oneOfType([ PropTypes.element, PropTypes.arrayOf(PropTypes.element) @@ -29,6 +30,7 @@ export class Frame extends Component { mountTarget: undefined, contentDidMount: () => {}, contentDidUpdate: () => {}, + contentWillUnmount: () => {}, initialContent: '
' }; @@ -97,12 +99,14 @@ export class Frame extends Component { const contentDidMount = this.props.contentDidMount; const contentDidUpdate = this.props.contentDidUpdate; + const contentWillUnmount = this.props.contentWillUnmount; const win = doc.defaultView || doc.parentView; const contents = (
{this.props.children}
@@ -129,6 +133,7 @@ export class Frame extends Component { delete props.mountTarget; delete props.contentDidMount; delete props.contentDidUpdate; + delete props.contentWillUnmount; delete props.forwardedRef; return (