Skip to content

Commit

Permalink
fix: Check for forwardedRef in withGlobalEvents (#7710)
Browse files Browse the repository at this point in the history
Fix #7707
  • Loading branch information
tofumatt authored and mcsf committed Jul 4, 2018
1 parent 35f5a28 commit 6bf9832
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion components/higher-order/with-global-events/index.js
Expand Up @@ -55,7 +55,12 @@ function withGlobalEvents( eventTypesToHandlers ) {

handleRef( el ) {
this.wrappedRef = el;
this.props.forwardedRef( el );
// Any component using `withGlobalEvents` that is not setting a `ref`
// will cause `this.props.forwardedRef` to be `null`, so we need this
// check.
if ( this.props.forwardedRef ) {
this.props.forwardedRef( el );
}
}

render() {
Expand Down

0 comments on commit 6bf9832

Please sign in to comment.