Skip to content

Instantly share code, notes, and snippets.

@njayman
Forked from jimfb/wrapper.js
Created July 4, 2018 20:48
Show Gist options
  • Save njayman/a8ffebcc21228faa785e853b8c7be7ca to your computer and use it in GitHub Desktop.
Save njayman/a8ffebcc21228faa785e853b8c7be7ca to your computer and use it in GitHub Desktop.
class MyWrapper {
return React.Children.only(this.props.children);
}
class MyLibraryComponent {
render() {
return <div><span><whatever><MyWrapper ref=...>{this.props.statelessComponentThatIWantToReference}</MyWrapper></whatever></span></div>;
}
}
// ReactDOM.findDOMNode(mywrapperref) effectively returns a reference to the stateless component.
// You can find the DOM node of the stateless component, etc.
// It no longer matters if your users are using stateless components or real components.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment