Skip to content

Instantly share code, notes, and snippets.

@njayman
Forked from jimfb/wrapper.js
Created July 4, 2018 20:48
Show Gist options
  • Select an option

  • Save njayman/a8ffebcc21228faa785e853b8c7be7ca to your computer and use it in GitHub Desktop.

Select an option

Save njayman/a8ffebcc21228faa785e853b8c7be7ca to your computer and use it in GitHub Desktop.

Revisions

  1. @jimfb jimfb revised this gist Feb 4, 2016. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion wrapper.js
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,8 @@ class MyLibraryComponent {
    }
    }

    // ReactDOM.findDOMNode(mywrapperref) returns a reference to the stateless component.
    // 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.


  2. @jimfb jimfb revised this gist Feb 4, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion wrapper.js
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,6 @@ class MyLibraryComponent {
    render() {
    return <div><span><whatever><MyWrapper ref=...>{this.props.statelessComponentThatIWantToReference}</MyWrapper></whatever></span></div>;
    }
    }
    }

    // ReactDOM.findDOMNode(mywrapperref) returns a reference to the stateless component.
  3. @jimfb jimfb created this gist Feb 4, 2016.
    11 changes: 11 additions & 0 deletions wrapper.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@

    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>;
    }
    }