inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

따라하며 배우는 노드, 리액트 시리즈 - 기본 강의

도저히 에러를 잡을 수 없어 질문드립니다 TT

223

안서영

작성한 질문수 1

0

×

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.
usePromise
C:/Users/98_07/Desktop/노드리액트/src/usePromise.ts:10
7 | });
8 | const isMounted = useRef(false);
9 | useEffect(() => {
> 10 | isMounted.current = true;
| ^ 11 | if (!promiseOrFn) {
12 | setState({
13 | loading: false,
Module../src/index.js
C:/Users/98_07/Desktop/노드리액트/boiler-plate/client/src/index.js:20
17 |
18 | ReactDOM.render(
19 | <Provider
> 20 | store={createStoreWithMiddleware(
21 | Reducer,
22 | window.__REDUX_DEVTOOLS_EXTENSION__ && // google redux 확장 사용 위함
23 | window.__REDUX_DEVTOOLS_EXTENSION__()
__webpack_require__
C:/Users/98_07/Desktop/노드리액트/boiler-plate/client/webpack/bootstrap:784
781 | };
782 |
783 | // Execute the module function
> 784 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
| ^ 785 |
786 | // Flag the module as loaded
787 | module.l = true;
fn
C:/Users/98_07/Desktop/노드리액트/boiler-plate/client/webpack/bootstrap:150
147 | );
148 | hotCurrentParents = [];
149 | }
> 150 | return __webpack_require__(request);
| ^ 151 | };
152 | var ObjectFactory = function ObjectFactory(name) {
153 | return {
1
http://localhost:3000/static/js/main.chunk.js:701:18
__webpack_require__
C:/Users/98_07/Desktop/노드리액트/boiler-plate/client/webpack/bootstrap:784
781 | };
782 |
783 | // Execute the module function
> 784 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
| ^ 785 |
786 | // Flag the module as loaded
787 | module.l = true;
checkDeferredModules
C:/Users/98_07/Desktop/노드리액트/boiler-plate/client/webpack/bootstrap:45
42 | }
Array.webpackJsonpCallback [as push]
C:/Users/98_07/Desktop/노드리액트/boiler-plate/client/webpack/bootstrap:32
29 | deferredModules.push.apply(deferredModules, executeModules || []);
30 |
31 | // run deferred modules when all chunks ready
> 32 | return checkDeferredModules();
| ^ 33 | };
34 | function checkDeferredModules() {
35 | var result;
(anonymous function)
http://localhost:3000/static/js/main.chunk.js:1:65
This screen is visible only in development. It will not appear if the app crashes in production.
위에가 화면이 뜨는 에러 사항이고
특별히 react나 react dom의 중복 없는 것 같고
코드도 몇번이고 확인해 보았으나 오류 원인을 찾기가 힘이 듭니다.
연관 있을 법한 파일들을 올려 봅니다....
client > pacakge.json
{
  "name""client",
  "version""0.1.0",
  "private"true,
  "dependencies": {
    "@testing-library/jest-dom""^4.2.4",
    "@testing-library/react""^9.5.0",
    "@testing-library/user-event""^7.2.1",
    "axios""^0.20.0",
    "http-proxy-middleware""^1.0.5",
    "react""^16.13.1",
    "react-dom""^16.13.1",
    "react-native""^0.63.3",
    "react-redux""^7.2.1",
    "react-scripts""3.4.3",
    "redux""^4.0.5",
    "redux-promise""^0.6.0",
    "redux-thunk""^2.3.0"
  },
  "scripts": {
    "start""react-scripts start",
    "build""react-scripts build",
    "test""react-scripts test",
    "eject""react-scripts eject"
  },
  "eslintConfig": {
    "extends""react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
server > package.json
{
  "name""boiler-plate",
  "version""1.0.0",
  "description""",
  "main""index.js",
  "scripts": {
    "start""node server/index.js",
    "backend""nodemon server/index.js",
    "test""echo \"Error: no test specified\" && exit 1",
    "dev""concurrently \"npm run backend\" \"npm run start --prefix client\""
  },
  "author": "ooo",
  "license""ISC",
  "dependencies": {
    "antd""^4.6.6",
    "bcrypt""^5.0.0",
    "body-parser""^1.19.0",
    "concurrently""^5.3.0",
    "cookie-parser""^1.4.5",
    "express""^4.17.1",
    "jsonwebtoken""^8.5.1",
    "mongoose""^5.10.7",
    "react-promise""^3.0.2",
    "react-router-dom""^5.2.0"
  },
  "devDependencies": {
    "nodemon""^2.0.4"
  }
}
LoginPage.js
import React, { useState } from 'react';
import Axios from 'axios';
import { useDispatch } from 'react-redux';
import { loginUser } from '../../../_action/user_action';

function LoginPage() {
  const dispatch = useDispatch();

  const [EmailsetEmail] = useState(''); // useState 안에 들어가는 내용은 초기 상태
  const [PasswordsetPassword] = useState(''); // Password(state) -> 유저가 입력한 내용이 들어감

  const onEmailHandler = (event=> {
    setEmail(event.currentTarget.value);
  }; // 타이핑을 즉시 반영하기 위함
  const onPasswordHandler = (event=> {
    setPassword(event.currentTarget.value);
  };
  const onSubmitHandler = (event=> {
    event.preventDefault(); //아무 것도 ( 이메일이나 비밀번호 입력)하지 않아도 버튼을 누르면 페이지가 리프레쉬됨

    let body = {
      email: Email,
      password: Password,
    };

    dispatch(loginUser(body)); //redux 사용, LoginUser == action
    /* 해당 내용은 LoginUser action에서 처리
    Axios.post('api/users/login', body)
    .then(response =>{ })*/
  };
  return (
    <div
      style={{
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center',
        width: '100%',
        height: '100vh',
      }}
    >
      <form
        style={display: 'flex'flexDirection: 'column' }}
        onSubmit={onSubmitHandler}
      >
        <label>Email</label>
        <input type='email' value={Email} onChange={onEmailHandler} />
        <label>Password</label>
        <input type='password' value={Password} onChange={onPasswordHandler} />
        <br />
        <button>Login</button>
      </form>
    </div>
  );
}

export default LoginPage;

react nodejs

답변 1

0

강민석

혹시 어떻게 해결하셨나요??

깃 이메일이랑 비번이 필요하다고 하네요

0

34

1

404 에러

0

101

1

34강 인증 체크에서 element 사용 때문에 에러나시는 분들 이렇게 하심 됩니다.

0

118

1

로그인, 로그아웃, 토근 작동 안 함

0

237

0

9강 오류 어떻게 해결하나요?

0

193

1

localhost 에서 연결을 거부했습니다.

0

1924

4

포스트맨에서 true가 안떠요

0

150

1

왜 안되나요

0

128

1

몽고db 연결 오류가 납니다 위에껀 입력한 코드, 아래껀 터미널이에요

0

243

1

로그아웃 401 에러(Unauthorized)

0

502

2

암호가 해싱되지 않고 입력값 그대로 db에 저장되는 문제

0

148

1

7강중에서

0

162

2

User.findByToken is not a function

0

210

1

루트 디렉토리

0

268

1

useState

0

560

1

프록시 잘 설정했는데도 404 오류 뜨는 분들

5

874

6

webpack 관련 에러 질문

0

218

1

리액트 관련 질문

0

271

1

14강 로그아웃 안됨

0

317

1

mongoDB 데이터 확인하는 법

0

407

1

postman 에러

0

290

1

선생님 리덕스를 사용하면 어떠한 부분이 좋은지 알 수 있을까요?

0

232

1

다음과 같은 에러들이 발생합니다.

0

271

1

14강 로그아웃 기능 구현시 postman에서 Cannot POST 오류가 뜹니다.

0

378

1