Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 3d5bf1a

Browse files
farwayerMax
authored andcommitted
Avoid to set refs on stateless components (#866)
1 parent 09cbedc commit 3d5bf1a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

CodePush.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,15 @@ function codePushify(options = {}) {
482482
}
483483

484484
render() {
485-
return <RootComponent {...this.props} ref={"rootComponent"} />
485+
const props = {...this.props};
486+
487+
// we can set ref property on class components only (not stateless)
488+
// check it by render method
489+
if (RootComponent.prototype.render) {
490+
props.ref = "rootComponent";
491+
}
492+
493+
return <RootComponent {...props} />
486494
}
487495
}
488496
}

0 commit comments

Comments
 (0)