• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

작동이 안되네요....ㅠㅠ

22.10.27 15:29 작성 조회수 355

0

Line 4:8: 'App' is defined but never used no-unused-vars

이러한 내용으로 에러가 뜨고

에러 라인 옆에 // eslint-disable-next-line << 주석도 달아봤는데 해결이 안됩니다..

답변 4

·

답변을 작성해보세요.

0

일단 setInterval 함수에서 interval 값이 빠져있네요~

아래와 같이 1000을 넣어주셔야 1초마다 새롭게 Clock 컴포넌트가 렌더링 됩니다.

setInterval(() => {
  root.render(
    <React.StrictMode>
      <Clock />
    </React.StrictMode>
  );
}, 1000)

 

그리고 처음에 Library 컴포넌트가 렌더링 되도록 되어 있는데,

이건 의도하신 건지 모르겠지만 Clock 컴포넌트 실습을 위해서는 처음 렌더링 할 컴포넌트도 Clock으로 바꿔주시는게 맞습니다.

이렇게 해서 한 번 해보시기 바랍니다~

그리고 첫 질문에서 안 된다고 하신게 전혀 실행이 안되는 것인지, 시계가 제대로 작동하지 않는다는 것인지도 명확하게 알려주시면 제가 답변을 하는데 도움이 될 것 같습니다!

0

김우람님의 프로필

김우람

질문자

2022.10.27

올려주신 깃허브에서 그대로 복사해도 안되는 중입니다 ㅠㅡㅠ

0

김우람님의 프로필

김우람

질문자

2022.10.27

import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

import Library from './chapter_03/Library';
import Clock from './chapter_04/Clock';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <Library />
  </React.StrictMode>
);

setInterval(() => {
  root.render(
    <React.StrictMode>
      <Clock />
    </React.StrictMode>
  );
})


// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

0

안녕하세요, 김우람님. 소플입니다.

시계 만들기 실습을 하면서 오류가 나신 건가요?

정확한 원인 파악을 위해서 작성하신 전체 코드를 첨부해주시면 감사하겠습니다!