반응형

react-hooks 24

이 usageRedexState 후크와 useSelector의 차이점성능 면에서?

이 usageRedexState 후크와 useSelector의 차이점성능 면에서? useLimensxState 후크를 썼는데 다음과 같다. import { useSelector } from 'react-redux'; const pick = (object, keys) => keys.reduce( (obj, key) => (object && Object.prototype.hasOwnProperty.call(object, key) ? { ...obj, [key]: object[key] } : obj), {}, ); export default (reducer, values) => pick( useSelector((state) => state[reducer]), values, ); 나는 이것을 다음과 같이 사용한..

Programing 2022.03.12

효과()를 올바르게 사용하는 방법?

효과()를 올바르게 사용하는 방법? 나는 스크롤을 해서 스타일을 바꾸고 싶다. 이 코드는 제대로 작동하지 않는다.내가 너무 많이 굴리고 너무 빨리 굴리면, 브라우저가 정지하고, 작동이 중단될 것이다. 나는 내가 사용했던 것 같다.useEffect()틀렸어. 어떻게 하면 이 문제를 해결할 수 있을까. const ArticleItem = ({title, content, active, chapter, program, id, scrollPos}) => { const ref = useRef(null); const client = useApolloClient(); useEffect(() => { if(ref.current.offsetTop { if(ref.current.offsetTop { window.addEve..

Programing 2022.03.11

참조에 이벤트 수신기를 추가하는 방법

참조에 이벤트 수신기를 추가하는 방법 ResactJS 후크 사용법에 이벤트 수신기를 추가하는 방법(버전 16.8. +) 여기 오버플로 오토로 어떤 div의 스크롤 위치를 얻으려고 했던 예가 있다.updateScrollPosition 부름을 받지 않는다. function Example(props) { scroller = useRef(); useEffect(() => { function updateScrollPosition() { // update the scroll position } if (scroller && scroller.current) { scroller.current.addEventListener("scroll", updateScrollPosition, false); return function..

Programing 2022.03.11

리액션 후크 "useContext"는 리액션 기능 구성 요소 또는 사용자 정의 리액션 후크 기능이 아닌 함수 "age"에서 호출된다.

리액션 후크 "useContext"는 리액션 기능 구성 요소 또는 사용자 정의 리액션 후크 기능이 아닌 함수 "age"에서 호출된다. 나는 useContext reaction 훅을 사용하고 있다. 연령.js import React, { useContext } from 'react' ; import Detail from '../context/detail'; const age = props =>{ const detail = useContext(Detail); return( Your age is : {detail.age} ); } export default age ; 다음과 같은 오류를 발생시킨다.React Hook "useContext" is called in function "age" which is ne..

Programing 2022.03.08
반응형