Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

use ref in component reactjs

function CustomTextInput(props) {
  // textInput doit être déclaré ici pour que la ref puisse s’y référer  const textInput = useRef(null);
  function handleClick() {
    textInput.current.focus();  }

  return (
    <div>
      <input
        type="text"
        ref={textInput} />      <input
        type="button"
        value="Donner le focus au champ texte"
        onClick={handleClick}
      />
    </div>
  );
}
Comment

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}      />
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: string en javascript 
Javascript :: concatenation of loop data in variable using jquery 
Javascript :: angular get firebase firestore 
Javascript :: what the cjs.js fiel use 
Javascript :: express request url ignores hash 
Javascript :: javascript block link action 
Javascript :: formatt json to create node and child node react 
Javascript :: js multibyte string length 
Javascript :: typeahead bootstrap 4 add multiple values 
Javascript :: how to disable autonumeric js 
Javascript :: java jsp attribute qualified names must be unique within an element 
Javascript :: recoilOutside npm 
Javascript :: code for random dom background image change 
Javascript :: string .length js 
Javascript :: london turnbridgewells 
Javascript :: bcrypt always return faslse in node js 
Javascript :: queryselect get type of elment class or id 
Javascript :: useMatch 
Javascript :: click on list item javascript highlight 
Javascript :: moment get end of next moenth 
Javascript :: CFBundleShortVersionString in app.json 
Javascript :: pase de fotos automatico javascript 
Javascript :: 18002738255 
Javascript :: email collapsible section 
Javascript :: understand frontend 
Javascript :: how to creat puzzle 15 at jq 
Javascript :: javascript arrays codeburst 
Javascript :: backbone js event listener 
Javascript :: When you run JavaScript in a Node.Js application, elements in a Node.JS Stack actually executes the JavaScript: 
Javascript :: multiple set in meteor user 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =