npm i -s react-router-dom
나는 권한 문제로 아래 코드와 같이 sudo를 활용하여 설치하였다.
sudo npm install -g styled-components
sudo 대신 npm 권한을 수정하여 잠재적인 문제를 피하는 것이 좋다하여 다음 명령어를 사용하여 npm 캐시 디렉터리의 소유권을 사용자로 변경하였다.
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules
위 명령어 실행 후 npm을 사용하여 설치를 진행하니 잘 설치되었다.
npm install styled-components
npm i --save moment
npm install react-icons --save
npm install --save redux
npm install --save redux react-redux
npm install @material-ui/core
--force 또는 --legacy-peer-deps 사용: npm install 명령을 실행할 때 --force 또는 --legacy-peer-deps 옵션을 함께 사용하여 종속성 충돌을 무시하고 설치를 진행할 수 있습니다.
npm install @material-ui/core --force
# 또는
npm install @material-ui/core --legacy-peer-deps
npm install @reduxjs/toolkit
--force 또는 --legacy-peer-deps 사용: npm install 명령을 실행할 때 --force 또는 --legacy-peer-deps 옵션을 함께 사용하여 종속성 충돌을 무시하고 설치를 진행할 수 있습니다.
npm install @reduxjs/toolkit --force
# 또는
npm install @reduxjs/toolkit --legacy-peer-deps
npm install firebase
--force 또는 --legacy-peer-deps 사용: npm install 명령을 실행할 때 --force 또는 --legacy-peer-deps 옵션을 함께 사용하여 종속성 충돌을 무시하고 설치를 진행할 수 있습니다.
npm install firebase --force
# 또는
npm install firebase --legacy-peer-deps
Firebase 콘솔(https://console.firebase.google.com/u/0/?hl=ko&_gl=1*r14pjd*_ga*MTU1OTAxNDI0LjE2OTE1NjA1MjI.*_ga_CW55HF8NVT*MTY5MTU2MDUyMi4xLjAuMTY5MTU2MDUyMi4wLjAuMA..)에 접속하고 Google 계정으로 로그인하세요.
"프로젝트 추가" 버튼을 클릭하여 새로운 Firebase 프로젝트를 생성하세요.
프로젝트 이름을 입력하고, 국가/지역을 선택한 후 "프로젝트 만들기"를 클릭하세요.
생성한 프로젝트 대시보드로 이동하여 "프로젝트 설정"을 선택하세요.
"일반" 탭에서 "웹 앱 추가"를 클릭하세요.
앱 별칭을 입력하고, 웹 앱 아이콘을 선택하거나 사용하지 않을 경우 "웹 앱 만들기"를 클릭하세요.
구성 정보 페이지에서 Firebase SDK 구성 정보가 표시됩니다. 이 정보를 복사하여 프로젝트 코드에 붙여넣을 준비를 해둡니다.
Firebase SDK 구성 정보를 프로젝트 코드에 붙여넣고, 필요한 모듈을 임포트합니다.
npm install redux-devtools-extension --force
npm install react-router --force
https://stackoverflow.com/questions/66465750/withrouter-is-not-exported-from-react-router-dom
withRouter가 react-router v6에서 제거되었으므로 자신만의 함수를 만들 수 있습니다.
import { useNavigate } from 'react-router';
export const withRouter = (Component) =>{
const Wrapper = (props) =>{
const history = useNavigate();
return <Component history={history} {...props}/>
}
return Wrapper;
}
https://velog.io/@bami/%EC%97%90%EB%9F%AC%ED%95%B4%EA%B2%B0-export-withRouter-imported-as-withRouter-was-not-found-in-react-router-dom
-> history가 react v5까지만 지원하고 v6부터 지원하지않아서 발생한 문제이다.
const navigate = useNavigate();를 추가하여 navigate 함수를 사용할 수 있습니다.
history.push('/')를 navigate('/')로 변경하였습니다.
history.goBack()을 navigate(-1)로 변경하였습니다.
ERROR
Cannot read properties of undefined (reading 'refs')
TypeError: Cannot read properties of undefined (reading 'refs')
at detach (http://localhost:3000/static/js/bundle.js:39223:3)
at http://localhost:3000/static/js/bundle.js:39296:9
at http://localhost:3000/static/js/bundle.js:39255:9
at safelyCallDestroy (http://localhost:3000/static/js/bundle.js:82671:9)
at commitHookEffectListUnmount (http://localhost:3000/static/js/bundle.js:82809:15)
at commitPassiveUnmountOnFiber (http://localhost:3000/static/js/bundle.js:84431:15)
at commitPassiveUnmountEffects_complete (http://localhost:3000/static/js/bundle.js:84411:11)
at commitPassiveUnmountEffects_begin (http://localhost:3000/static/js/bundle.js:84402:11)
at commitPassiveUnmountEffects (http://localhost:3000/static/js/bundle.js:84356:7)
at flushPassiveEffectsImpl (http://localhost:3000/static/js/bundle.js:86179:7)
allow read, write: if false; -> allow read, write: if true;
수정