Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

pass ref to class component react

class ElemComponent extends Component {
  render() {
    return (
      <div ref={this.props.innerRef}>
        Div has a ref
      </div>
    )
  }
}

export default React.forwardRef((props, ref) => <ElemComponent 
  innerRef={ref} {...props}
/>);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pass #ref #class #component #react
ADD COMMENT
Topic
Name
7+6 =