useref in react hooks

Solutions on MaxInterview for useref in react hooks by the best coders in the world

showing results for - "useref in react hooks"
Jacopo
03 Jun 2017
1/*
2	A common use case is to access a child imperatively: 
3*/
4
5function TextInputWithFocusButton() {
6  const inputEl = useRef(null);
7  const onButtonClick = () => {
8    // `current` points to the mounted text input element
9    inputEl.current.focus();
10  };
11  return (
12    <>
13      <input ref={inputEl} type="text" />
14      <button onClick={onButtonClick}>Focus the input</button>
15    </>
16  );
17}
Claudia
15 Mar 2018
1import React, {useRef, useEffect} from "react";
2
3export default function (props) {
4  // Initialized a hook to hold the reference to the title div.
5  const titleRef = useRef();
6  
7  useEffect(function () {
8    setTimeout(() => {
9      titleRef.current.textContent = "Updated Text"
10    }, 2000); // Update the content of the element after 2seconds 
11  }, []);
12  
13  return <div className="container">
14    {/** The reference to the element happens here **/ }
15    <div className="title" ref={titleRef}>Original title</div>
16  </div>
17}
Said
14 Aug 2019
1import React, { useRef } from 'react';
2
3function TextInputWithFocusButton() {
4  const inputEl = useRef(null);
5  const onButtonClick = () => {
6    // `current` points to the mounted text input element
7    inputEl.current.focus();
8  };
9  return (
10    <>
11      <input ref={inputEl} type="text" />
12      <button onClick={onButtonClick}>Focus the input</button>
13    </>
14  );
15}
Lola
05 Jul 2017
1import React, { useEffect, useRef } from 'react';
2
3const fooComponent = props => {
4	const inputBtnRef = useRef(null);
5  	useEffect(() => {
6      //Add the ref action here
7      inputBtnRef.current.focus();
8    });
9  
10  	return (
11      <div>
12        <input
13          type="text"
14          ref={inputBtnRef} 
15		/>
16      </div>
17    );
18}
Gabin
18 Jan 2017
1const refContainer = useRef(initialValue);
2//useRef returns a mutable ref object whose .current property is initialized to the passed argument (initialValue). 
3//The returned object will persist for the full lifetime of the component.
Merlin
09 Aug 2020
1import { useRef } from 'react';
2
3function LogButtonClicks() {
4  const countRef = useRef(0);  
5  const handle = () => {
6    countRef.current++;    console.log(`Clicked ${countRef.current} times`);
7  };
8
9  console.log('I rendered!');
10
11  return <button onClick={handle}>Click me</button>;
12}
queries leading to this page
react memo hookreact useref current functionsuseeffect doesnt trigger after ref updateuseref containsuseref hook tutorialuse api hook reactif will use callback in action what is the role of reducer reactuserefreact nativereact useref class componentuse reducer hookuseref hook examplesref hook reactaccess dom in useref and useeffectreact can i make userefreact useref initial valuereact memo hook inhttps 3a 2f 2freactjs org 2fdocs 2fhooks reference html 23usestatedeviffy react hooksreact mutable refuseref react class componentuseref react parametersuse memo in react jsreact hooks what is userefreact component userefusememo hook exampleuse ref in hooksref react hooks for listuseref in react hooksmemo react hookuseref on custom componentusememo exampleuseref save on closereact useref assigncreating ref using react hooksuseref 28 29 hookhow does useref work in reactwhat does useref do react jswhy do we useref in reactwhy we use useref in reactreact useref to call component functionuseref in useeffect react library testinguseref current methodsreact native class compinent userefuseref react how to useuseeffect where to get user fromuseref hook useeffectuseeffect hook while getting userreact hook userefreact useref as a stateuseref in class componentuseref rectuseref react with api callsreact userrefreact useref examplecomponent not re rendering on usedispatchuseref dom elemet reactjsdoes useref work in class componentuseref 28 29 react hooksuseref dom element react jshow to use ref in react hookreact hooks ref vs stateexample react userefhow react useref workshow to use useref function componentsreact hooks dependencyuseref in hook reactcontext api react hookshow to use useref in react hooksuseref this componentreact multiple userefs testingwhat is useref hook in reactwhat does useref 28 29why userefs or ref in reactreact hooks on initializereact useref currentuse useref in reactwhy useref is used in reactreact useref renderuse callback when changed react hookuseref on react componenthow to useref in class componentcreate ref inside usestatereact useref 28 29useref hook explaineduseref on component reactuseref on react hooksunable to use srcobject with useref hoolreact useref 28true 29import react 2c 7b useeffect 2c useref 2c usestate 7d from 27react 27usereff hookmutable ref object meansreact usereffwhat is react useref 3fuseref from reactreact useref 27usecallback docsreact usereff hookhow to use useref on your componentsreact useref methodreact useref set dom property ref userefreact useref 28 7b 7d 29how to useref in reactupdate ref hookuses of userefreact native react useredreact use memowhat is the useref hook in reactjs userefreact usestate documentationproperties using react hooksreact set ref userefreact use ref hook examplewhat is the use of useref in reactwhat is the useref hook used for in reactuseref hook what isuseref react componentsuseref docreact hooks component referenceuse effect with dispatch reactreact set ref hooksuseeffect dependenciesuseststate api react hook 22useref 22 is called in functionuseref reactjsuseref hook react jsreact what is userefuseref in react hookuse callback react hookreact useref as objectcomplete list of react hooksreact use callbackjavascript userefuseref trong reactjswhy useref isused in reactjsrefs with hooksusememo react jsfunctional components userefreacr userefuseref in class component reactuserefreact useref functional componentreact userref hookreact how to update userefvaluereactjs userefsuseref react native userefcreate context react hooksassign a ref useref function componentlist of react hooksuseref set a refuseref 28 7b 7d 29react useref get elementuseref type reactreact render from userefrefs react hooksreact hooks usecontext examplereact hooks dependenciesuseref initial state why 3fcreate ref hookreact useref variableuseref to statehow to use refs in react hooksusecontext in reactpass string in userefreact useref setuseref documentationreact js useref exampleuseref variable examplereat hook refreact useref on divopen component using useref in reactuse refuseref react native hookuseref a link in reactreact js useref currentuseref 28 29 react installuseref in react examplereact useref across componentsreact native useref examplereact hooks referenceuseref div reactrefs in react hooksuseref hooksuseffect return ref is null provider react hookusecallbackuseref in class components reactuseref for an elementref useref reactuseref current react 5dwhat is useref state hookcan we use react hook useref in class componentsuseref 28 29 react js all propertiesuseref example in reactmemo hooksreact useref componentuseref in react how to use itpre page refresh hook reactuseref lazy callbackwhat to set useref aswhat does it mean useref in reactwhat is the work of useref by exampleuseeffect useref nullreact useref apireact userefsreact usereffectusereducer react examplehooks forwardref as mutable objectref hook react nativeuseref 28 29 current functionscallback with react hooksunderstand react userefuseref importassign component to a ref in useffectreact hooks sorbuttonuseref hook in reactuseref as variableuseref include reacjsuseref react isreactjs useref valueuseref in reactjsusing react userefuseref in functional componentreact ref and userefuseref use react exampleref in react hooksreact useref alternative functional componentinput ref in hookreact useref examplereact native useref classuseref react importuse memo hooks reactnativeuse state reacthow to useref in a classreact class hooks refload indicator on rect usememoreact how to userefuseref in react jsusing useref instead of usestateuseref current reactuseref reactuser defined useeffect useref 28 29 3breact use userefuse ref reactuseref in reactuseeffect and useref in react importreact use call back hookuseref for variable reactwhat is useref 28 29react hooks context apihow to use useref 28 29react hook referencereact hook use refswhat is useref reactwhat is ref and useref reactreact hooks get ref valuehow to use useref hook reacreact usecontext examplereact useref tutorialusetouchripple react hookwhere to use useref react jscan i use useref in class componentsfew useref reactlear react userefuseeffect 28 29 2c usestate 28 29 2c useref 28 29 set ref hookreact hook create ref referenereact native useref const functional componentall hooks reactuseref ruleshow to make ref in hooksuseref hook reactuseref on number in reactuserf reactuseref react functional componentreact native useref examplereact memo hooks examplereact suserefreact object userefreact hook rfhicreate ref in react hookwhy do we need useref in reactreact callback hooksusestate commituseref in form reactreact memo hooksuseref input reactuseref syntaxreact useeffect and refuseref hook react nativesyntax of userefreact native useref updatehow to use useref in react native functional componentuseref current functionuseref get elementuseref call functionuseref 28 29 examplereact hook previous stateuseref in react fun componentsreact useref in functional componentreact dom or userefusing useref in react jsuseref forwardref react hookscreate ref in hooksreact useref with classuseref set functionwhat is useref in react hookswhen use useref in reactreact useref insert jsxusereff rectuseref in react jsreact useref how to set reffunction userefusecontext reactusing useref to store values in useeffectuseref 28 29 react documentationwhat does useref mean in reactwhy should i use useref in react jsreact useref in class componenthow useref works in reactreact useref hooksreact effect dependencieswhat is useref in react nativecustom refs in react hooksreact function component userefuseref react native hookreact effect dependency listreact useref current 21useref on jsxreact useeffect functional updatehttps 3a 2f 2freactjs org 2fdocs 2fhooks reference html 23useeffectreact context reduceruseref form reactereact userefuseref is a react hook 3fuseref react functional component example react memo hooksuseref objectref hookswhat is useful for useref reactuse of useref in reactwhat is use of useref in react jsuseref react id exampleuseref elementuseref apireact hook apireact hooks get nodehttps 3a 2f 2freactjs org 2fdocs 2fhooks reference html 23userefreact element userefhook render three propertycan useref be on jsx elementcan you useref in different componentsuselayouteffect reactupdating api with react hookreact use api hookreact hooks userefusecontext hook exampleuseref with functionreact usereacteffectaccess userefhow to useref in useeffect in reactreactjs apply useref to function componentreact using useref and useeffectuse ref in reacthook ref get valueshook create refuseref react divref react hooksreact native usecontextparameters in userefpassing function to userefjs ref hook for formwhat does creatref and useref do in reactuseref react hookuseref current 28 29react useref current methodsuseref for statereact useref 3freact useref in useeffect dependencyreactjs ref hookscreate ref hook reactreact useref render on changereact userefcall useeffect after useref is createdreact js hooks userefdo ref update react userefreact useref function componentreact what is useref hookcallback refs with hooksreact useref hooksuseref react get valueis react useref goodreact usereducerclass component userefcall useref in useeffectreact useref 28 29useref in react native examplereact useref to get elementuseref in input in react jsreact hooks how do i render an api objects resultref hook react ref in reactupdating the dom react useref and useeffectwhy do we need useref in react jsreact native usecallbackusecallback reactusing useref react hooksdefer useref reactuseref default valuereact use effect use callbackreact useref with id using useeffect and userefsuseref react formuseref on elementreact context hooks exampleuseref react idreact usecallbareact useref in hooksusing ref in react native hooksuseeffect in reactuseref as stateuseref in reactuseref currentwhat goes inside 28 29 in userefreact useref and useeffectis useref is hookuseref react reactusestate refuseref react useusing ref with hookscallback react hooksreact js userefref hooks in react tutoriareact useeffect and userefusestate react setstate dependandy of useeffecthow to use useref in reactclass component to functional component userefref component react hooks userefhow does useref work reactuseref usestate useeffect example and explanantionreact use currentreact usereff in a functionreact dependencies listreact useref counterhow to use useref in class componentreact useref in stateuseref example in fuction based componentassign new component to useref react hookreact js useref for htmlwhy i have to use current with useref in react jshow to use react hook refuseeffect after userefreact usereducer renderingreact class component userefuse reference hookwhat can go in userefreact native useref how use itreact refhookuserref react with api callsuseref document reactchech context states inside useeffect synchrolleyuseref in react native examplehooks react userefhow to use the useref hookusememo reacttesting react userefref in hooksuseref react examplereact useref in componentreact useref documentationhow to use useref in react stateuseref change classuseref in a functionare useref dependencies of useffectuseref element in reactgoogle react hooks useref callbackmutable refhow to get with userefset useref to trueuseref 28 29 react nativeapply ref in react hooks 28el 29 3d 3e current 5bi 5d 3d el useref reactreact usememofunction returned from useref reactuseref hookreact hook for this refcreate a ref for a react hook functionusestate in react memoreact native hooks useffect 2cusestate 2cuserefuseref hook example span useeffectreactjs when to use userefuse in react userefuse of useref hook in reactuseref on class componenthook use refuseref current 3d 3d 3d undefinedcall useeffect after useref are createdreactjs hook memoassign object in usereffor what is useref 28 29 3breactjs useeffect dependencyreact useref usestateuseref reacr docuseref react variablesreact hooks useref useeffectset ref react hooksuseref equivalentreact js usecontext examplereact userefduseref 28 29 reactreact use refuseref hook exampleuseref hook rectjsreact useeffect vs userefuse effect insert userefwhat type should i use with useref in reactuseref contains react jsreactjs useref on componentref hook input useref usage in react tablereact when to use userefreact hooks listuseref addyseref reacthow to useref in react hookreact useref propsuseref react functiondispatch usecallbackreact usestate useeffect useref usereducer usecontextreact hook for refuseref in jsreact hook get value from referencereact component class userefwhat is the useref hookwhy we are use useref in reactreact usehistory in useeffectuseeffect call on userefuseref undefineduseref value reactref is null in useeffectreact usecallbackusememo hook in reactuseref 28 29 in react nativeusing useref in reactwhy useref reactusing useref in reactjsuseref undefined in useeffectfunction components react userefusing regerential types useeffectreact hook memoreact useref a hrefhow to use ref hook to get value inside a function reacthookuseref documentationreact functional component useref what is it for 3freact functional components userefcheck useref in react native updateuseref methodshow to use ref in react with hookreact hook usereffectusered reactreact hooks add refuseref dom elementreact useeffect userefuseref null in useeffectreact useref hook on custom componentmemo react stateusereef reactusereducer setstate hooksreact hooks and context apireact ref hook typeuseref reactnative with class componentreact useref get stateuserstate 28 29 26 usereffectreact useref as propsreact useref call functionhow to useref 28 29 in class in reacthooks memouseref react docshow to react class component userefuseref in useeffect callbackuseref 28 29 rect docreact hooks setstate prevstateuseref 28react hooks using refsreact useref can you set the valuereact function component useeffect userefreact useref useeffect dependencyreact userefhow to set useref in react class componentusecallback in react nativereact useref inside classuse ref react hooksuseref with variables useref is are a react hook 3fuseref with usestate reactuseref in react defineduseref react 3fhow to use useref new react versionshow to useref on functional component reactreact using userefwhat are userefs or ref in reactuseref react styleuseref in useeffect dependenciesstabledispatch hookcontext provider react hooksusecallback hookrender useref elements reactwork useref with class componentshooks use refreact useref vs usestateref undefined in useeffectreact functional component userefreact js useref toggle dicupdate useref value reactreact hooks on initreact functional userefhooks react handlerreact useref explaineduseref react valuereact useref default valueuesref reqct hooksreact hooks propwhat is react userefmemo react hooksreact useeffect breaking other usereffectsupdate react hooksreact useref directly on a componentreact useref currenthook react alluseref current methodsreact hooks use callbackdifferent between useref and usestateuserefs reactusing useref for dom elementuseref react definationuseref hook with componentuse ref in react hooksreact createref in usestateuse reducercallback useeffectif will use callback in action what is the role of reducer react nativeuseref and useeffect in class componentuseref hook in react jshow to use react userefreact useref for function react context with hooksreact useref in class componentuseref javascriptuseref listcreate ref reacthookuseref with idrefs in hookswhat is useref rectuseref setstateusing useref insteaduseref example reactreact usememo unlessusereducer react nativereactjs useref at other componentreact useref function using use refreact usestate apiuseref in react class componenthook react userefreact useref with function decalarationreact js userefwhat does useref do in reactre render usestate userefwhat is useref in react reactjs orghow to get value in 5but in react js hoockreact usecontextusing ref in react hooksuse memo hooks use reactdeps react propertiesreact useref set currentuse contexxt hookreact built in hookshook refreactjs useref examplereact use refuseref in react nativewhen i am using useref hooksreact hooks use refhow to useref in react jsreact hooks ref exampledefait initial function in userefcreate ref hooksuseref current react functions 27useref 27 with react clasuseeffect ref dependencyuse of useref hookreact use memo hookdependency hookhow to set useref in a functionreact useeffect usecontext uselayout events orderuse ref hookusestate dependencyreact hooks previous statereact useref dom nodehooks refreact hook on initreact functional components useref functionsstore it in a useref hook and keep the mutable value in the 27 current 27 property otherwise 2c you can move this variable directly inside useeffectuseref state reacthow to use useref reactreact hooks refsreact useref useeffectreact useref elementreact useref currentreact refs and usestateuseref in react exampehow to use useref in react class componentwhat does useref do reactuseref for anchor tagreact native 2b userefcreate ref of state i hooksreactjs hook refreact hooks callbackuseref useeffect reacthow to use ref with hooksreact hook setrefref hook pass in function reactuserref in functional componentreact hooks memouseref 28null 29useref hooks reactwhat is useref for reacthow to use usecallback in react orghow to use useref after useeffectuseref react docuse imperative handleuseref usingusing useref in useeffectcreate a ref in a hookuseref setref reactuseref class component reactreact useref docusereference reacthow to use useref and refuseref react without hookscurrent in useref hooks reactconter funcion in react js with userefreact useeffect in singel user pagereact create ref with hooksreact native useref currenthow to make a state out of userefreact hooks use memouseref react hook exampleusereducer update in normal functionausereducer reacthook userefset useref truechange value userefuseref react elementreact memo docsreact useref with stateref hook in reactuse ref with react hooksmeaning useref reactjswhat is useref hook in react jsreact native useeffect 3a createuseref react currenthow to use context api with hooksreact native update userefreact useref in usecontext examplecontext reducer reactuseref function returned reactuseref examplewhen do we use useref in reactreact refs hookswhat is useref in reactlist of hooks in reactusereffect hookusecontext hook in reactuseref recat hookreact hook ref currentuseref react native exampleusing useref hookdifferent elements useref reactusereducer exampleusererf reacct nativeuseref with javascript object reacthook useref reactreact userefsuseref react hooksreact docs userefuseref jsfor what is useref used reactuseref to this component reactwhat is use of useref in reactreact useref methodsusecontext hook reactpass component reference to function in react hooksfunctional update react hooksconst todonameref 3d useref 28 29 3breact usememo on usereduecerreact useref current in class componentuseref react tutorialuse of react hook use refreact useref currentreact when is useref calleduseref in rectref hookinstall useref hook in reactreact dom useref htmlhow to use useref hookuseref for class componentuseeffect listen for new useref valuereact hook refwhat does useref doreact ref userefreact context hooksuseref set valueis we can use useref in class componentuse ref with hooksusing useref reactusereducer in reactref in hookreact import userefreact use state as refreact js use useref inside classreact useref examplesusememo hook react nativeis useref a react hook 3frect usecontextuseref example react jsget updated ref value in react hookall the react hooksuseref react componentprops manipulation using useref hooksuseref inputuseeffect callbackuseref hooks example react jsuseref 28 29useref react invokedusememo in reactreact useref hookreact useref inside useeffectuseref refuseref widuseref to an element reactuseref in component classuseref function reacthook useref documentationuseref in hookuse callback react examplereact hook dependenciesrecat userefreact usememo examplereact callback hookdoes useref work on react elementuseref on a react compoentnreact native ref hooksreact useref this propsuse ref exampleuseref in react functional componentreact useref 28 29 3bhow best to useref react hooks inside a setstate functionreact ref hookhooks create refchange value for ref in react hookcall useeffect after userefs are createduseref 280 29uselayouteffect react native examplewhat is useref hookuseref 28 29 react js react userefreact hooks refreact usereducer contextconst usernref 3d useref 28 29ref current is undefined useeffectuse useref for set statereact useeffect dependenciesusereference in reactuseref example using reactusecallback decumentation reactreact hooks userefreact useref valueusecallback react hooksreact use ref hookreact useref optionsuseref html elementusememo hookhow to reference a hook in a functionusecallback useref depswhy useref 28 29ref react hooks input react usestate previous statereact class userefreact org useref hookreactj ref hookuseref inside react stateuseref for a functiondifference between useref and useeffectuseref usage in reactuseref lifecycleuseref react hooks examplereact input ref useref hookreact hooks useforwardingrefuseref for functions in reactreact hook ref guidereact useref current for dhttps 3a 2f 2fmedium com 2ftrabe 2freact useref hook b6c9d39e2022atauseref hook in react nativeuseref react js hooksuseref inside functionreact hook update argumentuseref react nativeusestate hook callbackuseref is undefineduseref react documentationreactjs userefuseref current 28 29react hooks callback vsuse memouseref functional component reactjsreact refobject with hooksreact js useref on a divusing useeffect and useref togetherfunction hook userefreact useref hokuseref hook react hookhow to handle useref inside react componentwhat is react userefuseref hook definitionuseref hook react docsreact cuando usar useimperativehandleuseref tutorial reactjsuseref fro dom manipulationare refs usually handled with useeffectuser useeffect reactwhatt is useref in react useref for functionprevious state react hooksmanipulating dom elements with react hook useref 28 29useref react current methodsis useref a react hookreact class component reducer hookusestate hook user data propswhat useref do in reactreact useref initialvalueimport userefwhat does useref react do 3fuseref cssshould i use useref in reactreact native ref hookuseref react hookuseref set reactwhy we use useref in react jsreact js useref hookuseref assign useref example divref 26 useref hooksreactjs hook property typeshow to use useref hook in reactreact useref pass a functionuseref initial value functionusestate and refsuseref react react useref objectreact 2c 28 useref 29how to use ref in hooksuseref react jsuseref component reactreact hooks set ref valueuseref react native hooksuser of useref react nativeuseref propertiesexample of userefreact usehook callbackfunction of userefuseref current reactuseref react hooks type arrayuseref as functionreact native useref hookuseref inside componentsfunction component create userefuseref react propsuseref initial useref reference objectuseref when to use renderuseref into react componentuseref 28 29 jsxreact native hooks listreact useref with hooks exampleuseref to rendercan we use useref inside class componentdispatch in react hookshookes refreact hooks prev statereact ref hooksreact useref hook examplewhat is the use of useref hookuseref in useeffect react react hooks referdefine useref in reactreact hooks input refcreate react ref hooksref hooks reactwhy do we need usereff in react jsnot able to use useref in react js in functional componentreact ref in hooksrn using useefect insted of reduxhow to use ref in react hooksreact useref for domsreact js useref in formreact useref stateuseref react native explainedinput ref react hooksreact usecallreact useref in useeffectwhen to use useref in reactuseref current in useeffect callbackusecallback in reactreact native useref current create ref in react hooksuseref 28 29 react hoookshow many times we can use useref in reactreact useref set refusestate dependenciesset userefreact useeffect on input useref valueuse useref 28 29 with form in functional componentuseref 28 29 as react mutableelementchange userefunderstanding useref in reactreact useref and created refreact useref 28null 29react hooks get refuseref 28true 29 html in userefuseref in functionhow to useref reactreach useref hookuseref usesuseref ref reactuseref 28 29 reactjsuseref react domunable to use srcobject with useref hookref react hookacreate ref react hookshow to use refhook to get value inside a function reactreact all hooksreact hook acces to self refreact hook callbackreact useref in classuserefer reactreact hook callbacks const child 3d usememo 28 28 29 3d 3e 28when we use useref 28 29setting a ref userefwhen to use useref reac jsreact useref how to useuseref in class component reactwhat does useref returngoogle react hooks userefuselayout effectuseref how to change the element in react functional componentwhen to use useref reactreact useimperativehandlereact useref c2 a5useref stateusestate for refsuseref 28 29 from another component react hookin which version of react offer userefreact native userefuse callback reactuseref in class componentsuselayouteffect returnmemo hook reacthow to use useref with componentsreact set userefuseref of react componentuseref is a react hookusereducer hook reactreact class based component userefwhat is useref 28 29 current 3freact hook use refusing userefreact useref 28how to use useref in react nativeuserref reactreact hooks provider as well as usecontextreact hook userrefuseref understand reactreact get reference without hookuseref import reactract useref hookreact userefguseref in react 3fwhy using userefuseref reacteact useref 28usecontext react nativeuseref 28 29 in reactuse of useref and usecallback in reactreact useref nedirreact usereftuseref hookuseeffect detect change of refuseref class componentuseref and refuseref classhow to use useref in react functional componentreact hooks useref exampleset ref in layouteffectreact js use effect dependencies react useref updateusecallback hook reactuseref 3c 7b 7d 3e 28 29react useref numberall react hooksuselayouteffect in reactjsreact ref dom userefreact userefreact native useref functional componentreact useref on componentreact refs with hooksreact update need useeffect 28 29 when using useref 28 29 3e 3fmemoize hook reactinput ref react hooklsusecallback hooksuseref hook functional componentuserefs react nativeuseref in functional component exampleref component react hooks useref useeffectuseref in react hooks