Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

use ref in component reactjs

function CustomTextInput(props) {
  return (
    <div>
      <input ref={props.inputRef} />    </div>
  );
}

class Parent extends React.Component {
  render() {
    return (
      <CustomTextInput
        inputRef={el => this.inputElement = el}      />
    );
  }
}
Source by fr.reactjs.org #
 
PREVIOUS NEXT
Tagged: #ref #component #reactjs
ADD COMMENT
Topic
Name
5+9 =