use-ref

useRef() Hook on a custom component

白昼怎懂夜的黑 提交于 2020-12-03 15:48:54
问题 I'm trying do create a Navigation Bar that when the user click on one of the links, the page scrolls to some section. In the code above, each element is a section of my page: <Navbar scrollFunc={scrollToRef} /> <Mainlogo ref={mainLogoRef} /> <Sales ref={salesRef} /> <Introduction ref={introductionRef} /> <Blog ref={blogRef} /> <Footer /> The 'refs' was declares as folowing, using the useRef hook: const mainLogoRef = useRef(null) const salesRef = useRef(null) const introductionRef = useRef

useRef() Hook on a custom component

北慕城南 提交于 2020-12-03 15:46:09
问题 I'm trying do create a Navigation Bar that when the user click on one of the links, the page scrolls to some section. In the code above, each element is a section of my page: <Navbar scrollFunc={scrollToRef} /> <Mainlogo ref={mainLogoRef} /> <Sales ref={salesRef} /> <Introduction ref={introductionRef} /> <Blog ref={blogRef} /> <Footer /> The 'refs' was declares as folowing, using the useRef hook: const mainLogoRef = useRef(null) const salesRef = useRef(null) const introductionRef = useRef

Map data using useRef Hook

和自甴很熟 提交于 2020-07-10 07:31:36
问题 I am following this: Merge two JSON data into one with particular key values Now, I added an useEffect() hook. How can I make use of useRef to store my result? This is an asynchronous function. const App = (props) =>{ let result = useRef () useEffect(()=>{ return()=> (result.current = [courtdata, balldata].reduce((p, q) => p.map((c, i) => Object.assign({}, {[c.court_id] : q[i].color})))) }.[someTrigger]) return( <ul> {result.current.map(r => ( <li> Court id - {r.court_id} | Ball colour - {r

Map data using useRef Hook

核能气质少年 提交于 2020-07-10 07:31:12
问题 I am following this: Merge two JSON data into one with particular key values Now, I added an useEffect() hook. How can I make use of useRef to store my result? This is an asynchronous function. const App = (props) =>{ let result = useRef () useEffect(()=>{ return()=> (result.current = [courtdata, balldata].reduce((p, q) => p.map((c, i) => Object.assign({}, {[c.court_id] : q[i].color})))) }.[someTrigger]) return( <ul> {result.current.map(r => ( <li> Court id - {r.court_id} | Ball colour - {r