인프런 커뮤니티 질문&답변
더미데이터와 포스터폼 만들기 강좌 질문
해결된 질문
작성
·
494
0
[제로초 강좌 질문 필독 사항입니다]
질문에는 여러분에게 도움이 되는 질문과 도움이 되지 않는 질문이 있습니다.
도움이 되는 질문을 하는 방법을 알려드립니다.
https://www.youtube.com/watch?v=PUKOWrOuC0c
0. 숫자 0부터 시작한 이유는 1보다 더 중요한 것이기 때문입니다. 에러가 났을 때 해결을 하는 게 중요한 게 아닙니다. 왜 여러분은 해결을 못 하고 저는 해결을 하는지, 어디서 힌트를 얻은 것이고 어떻게 해결한 건지 그걸 알아가셔야 합니다. 그렇지 못한 질문은 무의미한 질문입니다.
1. 에러 메시지를 올리기 전에 반드시 스스로 번역을 해야 합니다. 번역기 요즘 잘 되어 있습니다. 에러 메시지가 에러 해결 단서의 90%를 차지합니다. 한글로 번역만 해도 대부분 풀립니다. 그냥 에러메시지를 올리고(심지어 안 올리는 분도 있습니다. 저는 독심술사가 아닙니다) 해결해달라고 하시면 아무런 도움이 안 됩니다.
2.Unhandled Runtime Error
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Check the render method of PostForm.
Source
components/LoginForm.js (15:4) @ eval
13 |
14 | const onSubmitForm = useCallback(() => {
> 15 | dispatch(
| ^
16 | loginAction({
17 | id,
18 | password,터미널 에러 메세지
/!\ You are using legacy implementation. Please update your code: use createWrapper() and wrapper.useWrappedStore().
4. withRedux(Sansbook) created new store with {
giapState: undefined,
gspState: null,
gsspState: null,
gippState: null
}
{}
4. withRedux(Sansbook) created new store with {
giapState: undefined,
gspState: null,
gsspState: null,
gippState: null
}
{}
3.
import React, { useCallback } from "react";
import { Button, Form, Input } from "antd";
import Link from "next/link";
import { useDispatch } from "react-redux";
import useInput from "./hooks/useInput";
import { loginAction } from "../reducers/user";
const LoginForm = () => {
const [id, onChangeId] = useInput("");
const [password, onChangePassword] = useInput("");
const dispatch = useDispatch();
const onSubmitForm = useCallback(() => {
dispatch(
loginAction({
id,
password,
})
);
}, [id, password]);
return (
<Form onFinish={onSubmitForm} style={{ padding: "10px" }}>
<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}
type="password"
required
/>
</div>
<div style={{ marginTop: "10px" }}>
<Button type="primary" htmlType="submit" loading={false}>
로그인
</Button>
<Link href="/signup">
<a>
<Button>회원가입</Button>
</a>
</Link>
</div>
</Form>
);
};
export default LoginForm;
import { Form, Input, Button } from "antd";
import { useCallback, useState, useRef } from "react";
import { useDispatch, useSelector } from "react-redux";
const PostForm = () => {
const { imagePaths } = useSelector((state) => state.post);
const [text, setText] = useState("");
const dispatch = useDispatch();
const imageInput = useRef();
const onChangeText = useCallback((e) => {
setText(e.target.value);
}, []);
const onSubmit = useCallback(() => {
dispatch(addPost);
}, []);
const onClickImageUpload = useCallback(() => {
imageInput.current.click();
}, [imageInput.current]);
return (
<Form
style={{ margin: "10px 0 20px" }}
encType="multipart/form-data"
onFinish={onSubmit}
>
<Input.Textarea
value={text}
onChange={onChangeText}
maxLength={140}
placeholder="어떤 일이 생겼나요"
/>
<div>
<input type="file" multiple hidden ref={imageInput} />
<Button onClick={onClickImageUpload}>이미지 업로드</Button>
<Button type="primary" style={{ float: "right" }} htmlType="submit">
짹쨱
</Button>
</div>
<div>
{imagePaths.map((v) => (
<div key={v} style={{ display: "inline-block" }}>
<img src={v} style={{ width: "200px" }} alt={v} />
<div>
<Button>제거</Button>
</div>
</div>
))}
</div>
</Form>
);
};
export default PostForm;
포스트폼까지 만들고 로그인버튼 누르면 저 에러가 뜨면서 안되네요 ㅠㅠ 에러메시지를 보면 LoginForm에 dispatch가 문제가 있다하고 PostForm 렌더링 방법을 한번 체크해보라는데 잘모르겠습니다





아 해결했습니다 Input.Textarea에서 a를 소문자로 써서 안나왔네요ㅠㅠ
감사합니다