Skip to content

Commit

Permalink
Components: Trigger require if prop reference changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Oct 28, 2016
1 parent c26d2c9 commit 7640e48
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions client/components/async-load/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ export default class AsyncLoad extends Component {
}

componentWillMount() {
this.require();
}

componentDidUpdate( prevProps ) {
// Our Babel transform will hoist the require function in the rendering
// component, so we can compare the reference with confidence
if ( this.props.require !== prevProps.require ) {
this.require();
}
}

require() {
this.props.require( ( component ) => {
this.setState( { component } );
} );
Expand Down

0 comments on commit 7640e48

Please sign in to comment.