Skip to content

React example is incorrect #109

@rus-yurchenko

Description

@rus-yurchenko

Hi there,
I found an issue with a React ref example. Inside a render() method you suggest to

pass your ref with the reference to the targetElement

But if we do so, we don't assign actually this.targetRef to the component and will always get a {current: null} from react ref.
Changed this.targetElement with this.targetRef worked for me.

render() {   
    return (
      // change this.targetElement with this.targetRef to actually access a react ref
      {/*<SomeOtherComponent ref={this.targetElement}>*/}
      <SomeOtherComponent ref={this.targetRef}>
        some JSX to go here
      </SomeOtherComponent> 
    );
  }

Please update the README example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions