«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Archives
Today
Total
Recent Posts
Recent Comments
관리 메뉴

뉴히의 개발 로그

[TIL] 20230828 - 오류 + 오류 + 오류ㅠㅠㅠㅠㅠㅠ !!!!!!!!!! slide custom 오류 react-dom.development.js:86 Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()? 본문

개발일지/TIL

[TIL] 20230828 - 오류 + 오류 + 오류ㅠㅠㅠㅠㅠㅠ !!!!!!!!!! slide custom 오류 react-dom.development.js:86 Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

뉴히 2023. 8. 28. 22:32

오류 1

react-dom.development.js:86 Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

함수형 컴포넌트가 직접적으로 ref를 사용할 수 없다는 것을 나타냅니다. ref를 사용하려면 함수형 컴포넌트를 React.forwardRef()로 감싸야 합니다.

예를 들어, ProfilesCard 컴포넌트를 React.forwardRef()로 래핑하여 ref를 사용할 수 있게 만들 수 있습니다. 

const ProfilesCard = ({ tutor }: pageProps) => {}


==> 


const ProfilesCard = React.forwardRef<HTMLDivElement, ProfilesCardProps>(
  ({ tutor }, ref) => {})

오류2

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'.

참고로 해당오류는 라이브러리 사용시 container / wrapper / slide 이런 순서대로 안해줫을때 나타나는 오류라고한다.

 

공식문서를 잘 보고 라이브러리 사용을 제대로 해야겠다.

custom 하려다가 시간을 엄청 잡아먹음 !