inflearn logo
강의

講義

知識共有

[リニューアル] ReactでNodeBird SNS作成

ダミーデータでログインする

Unhandled Runtime Error

622

new01260170

投稿した質問数 6

0

아이디랑 비밀번호 입력하고
로그인 누르면 다음과 같은 에러가 표시 되네요 ㅜㅜ
 
 
 
 
 
LoginForm.js
 
UserProfile.js
 

nodejs react redux express Next.js

回答 5

0

new01260170

아 죄송합니다 제가 뭘 빼먹었었네요 잘 동작됩니다 ㅜㅜ

0

new01260170

아 오타가 있었네요 LggedIn

근데 그거 오타 수정해도 똑같은 에러가 나네요 ㅜㅜ

 

0

new01260170

아 네 알겠습니다.

AppLayout 코드 입니다.

import { useState } from 'react';
import PropTypes from 'prop-types';
import Link from 'next/link';
import { Input, Menu, Row, Col } from 'antd';
import UserProfile from '../components/UserProfile';
import LoginForm from '../components/LoginForm';
import styled from 'styled-components';

const SearchInput = styled(Input.Search)`
vertical-align: middle
`;

const AppLayout = ({ children }) => {
// ToDo
const [isLoggedIn, setIsLoggedIn] = useState(false);
return (
<div>
<Menu mode="horizontal">
<Menu.Item key="home">
<Link href="/"><a></a></Link>
</Menu.Item>
<Menu.Item key="profile">
<Link href="/profile"><a>프로필</a></Link>
</Menu.Item>
<Menu.Item key="search">
<SearchInput enterButton />
</Menu.Item>
<Menu.Item key="signup">
<Link href="/signup"><a>회원가입</a></Link>
</Menu.Item>
</Menu>
{/* column 사이 간격: gutter */}
<Row gutter={8}>
<Col xs={24} md={6}>
{isLoggedIn ? <UserProfile setIsLoggedIn={setIsLoggedIn} /> : <LoginForm setIsLoggedIn={setIsLoggedIn} /> }
</Col>
<Col xs={24} md={12}>
가운데 메뉴
</Col>
<Col xs={24} md={6}>
오른쪽 메뉴
</Col>
</Row>
{children}
</div>
)
}

// children 값이 있는지 체크하기 위한 용도
AppLayout.propTypes = {
children: PropTypes.node.isRequired,
};

export default AppLayout;

1

zerocho

<UserProfile setIsLoggedIn={setIsLoggedIn} /> : <LoginForm setIsLoggedIn={setIsLoggedIn} />

 

위에서 오타가 이거 말씀드린 겁니다. setIsLggedIn 으로 하셨습니다.

0

new01260170

오타는 아닌 것 같습니다. 대소문자까지 같이 해서 확인해 봤어요.
로그인 폼 코드 붙여넣기 해서 드립니다.

 

import { useState, useCallback, useMemo } from 'react';
import PropTypes from 'prop-types';
import { Form, Input, Button } from 'antd';
import Link from 'next/link';
import styled from 'styled-components';
 
const ButtonWrapper = styled.div`
margin-top: 10px;
`;

const FormWrapper = styled(Form)`
padding: 10px;
`;

const LoginForm = ({ setIsLoggedIn }) => {
const [id, setId] = useState('');
const [password, setPassword] = useState('');
const onChangeId = useCallback((e) => {
setId(e.target.value);
}, []);

const onChangePassword = useCallback((e) => {
setPassword(e.target.value);
}, []);

const style = useMemo(() => ({ marginTop: 10}), [])

const onSubmitForm = useCallback(() => {
console.log(id, password);
setIsLoggedIn(true);
}, [id, password]);
 
return (
<FormWrapper onFinish={onSubmitForm}>
<div>
<label htmlFor="user-id">아이디</label>
<br />
<Input name="user-id" value={id} onChange={onChangeId} required />
</div>
<div>
<label htmlFor="user-password">비밀번호</label>
<br />
<Input name="user-password" value={password} onChange={onChangePassword} required />
</div>
<ButtonWrapper style={style}>
<Button type="primary" htmlType="submit" loading={false}>로그인</Button>
<Link href="/signup"><a><Button>회원가입</Button></a></Link>
</ButtonWrapper>
</FormWrapper>
);
}

LoginForm.propTypes = {
setIsLoggedIn: PropTypes.node.isRequired,
};

export default LoginForm;

0

zerocho

로그인 폼 코드 말고 로그인폼을 사용하는 코드를 올려주세요.

0

zerocho

setIsLggedIn 오타 아닌가요? 로그인폼을 쓰고있는 코드도 알려주세요.

0

new01260170

아래 댓글에 코드 넣었습니당 ㅜㅜ 

넥스트 버젼 질문

0

79

2

로그인시 401 Unauthorized 오류가 뜹니다

0

91

1

무한 스크롤 중 스크롤 튐 현상

0

177

1

특정 페이지 접근을 막고 싶을 때

0

104

2

createGlobalStyle의 위치와 영향범위

0

97

2

인라인 스타일 리렌더링 관련

0

93

2

vsc 에서 npm init 설치시 오류

0

148

2

nextjs 15버전 사용 가능할까요?

0

160

1

화면 새로고침 문의

0

123

1

RTK에서 draft, state 차이가 있나요?

0

155

2

Next 14 사용해도 될까요?

0

452

1

next, node 버전 / 폴더 구조 질문 드립니다.

0

349

1

url 오류 질문있습니다

0

211

1

ssh xxxxx로 우분투에 들어가려니까 port 22: Connection timed out

0

378

1

sudo certbot --nginx 에러

0

1282

2

Minified React error 콘솔에러 (hydrate)

0

470

1

카카오 공유했을 때 이전에 작성했던 글이 나오는 버그

0

249

1

프론트서버 배포 후 EADDRINUSE에러 발생

0

329

1

npm run build 에러

0

519

1

front 서버 npm run build 중에 발생한 에러들

0

383

1

서버 실행하고 브라우저로 들어갔을때 404에러

0

339

2

css 서버사이드 랜더링이 적용되지 않아서 문의 드립니다.

0

289

1

팔로워 3명씩 불러오고 데이터 합쳐주는걸로 바꾸고 서버요청을 무한으로하고있습니다.

0

242

2

해시태그 검색에서 throttle에 관해 질문있습니다.

0

202

1