inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

172만명의 커뮤니티!! 함께 토론해봐요.

안녕하세요 아직 수강중이긴한데 실무에서 작업중 궁금한게 있어서 질문드립니다!

해결됨

Next + React Query로 SNS 서비스 만들기

안녕하세요, 강의는 수강중이기도하고 아래에 비슷한 맥락의 질문이 있는데 제가 이해한게 맞나 궁금해서 질문 올립니다! 현재 next14 버전과 styled-component를 사용중이며 공식문서 https://nextjs.org/docs/app/building-your-application/styling/css-in-js#styled-components 내용 과 검색등을 통하여 적용하였습니다. // libs/styledCompnents/Registry.tsx 'use client'; import { useServerInsertedHTML } from 'next/navigation'; import { ReactNode, useState } from 'react'; import { ServerStyleSheet, StyleSheetManager } from 'styled-components'; const Registry = ({ children }: { children: ReactNode }) => { const [styledComponentsStyleSheet] = useState(() => new ServerStyleSheet()); useServerInsertedHTML(() => { const styles = styledComponentsStyleSheet.getStyleElement(); styledComponentsStyleSheet.instance.clearTag(); return <>{styles}</>; }); if (typeof document !== 'undefined') { return <>{children}</>; } return ( <StyleSheetManager sheet={styledComponentsStyleSheet.instance}> {children} </StyleSheetManager> ); }; export default Registry; //libs/styledComponets/Provider.tsx 'use client'; import { ThemeProvider } from 'styled-components'; import GlobalStyles from '@/styles/GlobalStyles'; import theme from '@/styles/theme'; import { PropsWithRequiredChildren } from '@/types/common'; import { StyledComponentsRegistry } from '.'; const Providers = (props: PropsWithRequiredChildren) => { return ( <StyledComponentsRegistry> <ThemeProvider theme={theme}> <GlobalStyles /> {props.children} </ThemeProvider> </StyledComponentsRegistry> ); }; export default Providers; // layout.tsx import type { Metadata } from 'next'; import { Inter } from 'next/font/google'; import AdminLayout from '@/layouts/AdminLayout/AdminLayout'; import { StyledComponentsProvider } from '@/libs/styledComponents'; import { MSWComponent } from '@/mocks/MSWComponent'; const inter = Inter({ subsets: ['latin'] }); export const metadata: Metadata = { title: 'Create Next App', description: 'Generated by create next app', }; export default function RootLayout({ children, }: { children: React.ReactNode; }) { return ( <html lang="en"> <body className={inter.className}> <MSWComponent> <StyledComponentsProvider> <AdminLayout>{children}</AdminLayout> </StyledComponentsProvider> </MSWComponent> </body> </html> ); } 현재 이렇게 사용중인데 AdminLayout에 'use client'를 사용하지않으면, 아래와 같은 에러가 나오고 'use client' 를 사용하면 에러 없이 렌더링이 정상적으로 됩니다. ``` Server Error Error: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component This error happened while generating the page. Any console logs will be displayed in the terminal window. Call Stack o node_modules/styled-components/dist/styled-components.esm.js (1:15911) (rsc)/./node_modules/styled-components/dist/styled-components.esm.js next/server/vendor-chunks/styled-components.js (30:1) __webpack_require__ next/server/webpack-runtime.js (33:42) eval webpack-internal:///(rsc)/./src/components/atoms/Text/Text.style.ts (5:75) (rsc)/./src/components/atoms/Text/Text.style.ts next/server/app/page.js (569:1) __webpack_require__ next/server/webpack-runtime.js (33:42) eval webpack-internal:///(rsc)/./src/components/atoms/Text/Text.tsx (7:69) (rsc)/./src/components/atoms/Text/Text.tsx next/server/app/page.js (580:1) __webpack_require__ next/server/webpack-runtime.js (33:42) eval webpack-internal:///(rsc)/./src/components/atoms/Text/index.ts (5:63) (rsc)/./src/components/atoms/Text/index.ts next/server/app/page.js (591:1) __webpack_require__ next/server/webpack-runtime.js (33:42) eval webpack-internal:///(rsc)/./src/layouts/AdminLayout/AdminLayout.tsx (10:80) (rsc)/./src/layouts/AdminLayout/AdminLayout.tsx next/server/app/page.js (745:1) __webpack_require__ next/server/webpack-runtime.js (33:42) eval webpack-internal:///(rsc)/./src/app/layout.tsx (10:90) (rsc)/./src/app/layout.tsx next/server/app/page.js (503:1) Function.__webpack_require__ next/server/webpack-runtime.js (33:42) async eq /node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js (35:401280) async tr /node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js (35:405046) async tn /node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js (35:405596) async tu /node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js (35:409938) async /node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js (35:410457) ``` 궁금한 점이 3가지가 있는데 검색만으로는 이해가 잘안되서 질문드립니다ㅠ 1. AdminLayout이 'use client'를 선언하지 않고 서버 컴포넌트로 사용을 하여도 StyledComponentsProvider 가 'use client' 이기 때문에 클라이언트 컴포넌트의 자식으로 AdminLayout을 사용하면 AdminLayout도 자동으로 클라이언트 컴포넌트로 변경되는걸까요? 아니면 자식 요소로 사용하는것은 상관없이 import 해오는 경우만 클라이언트 컴포넌트에서 서버 컴포넌트를 불러오면 서버 컴포넌트가 클라이언트 컴포넌트가 되는걸까요? 2. 컴포넌트의 자식이 부모의 컴포넌트의 상태를 따라간다면, 만약 최상위 부모 (Layout)가 클라이언트 컴포넌트라면 어차피 AdminLayout 이나 불러오는 NavMenu 들을 서버 컴포넌트로 사용 못하는게 맞나요? 3. 강의상 진행할때는 문제 없었습니다. 현재 위에 질문드린 에러는 styled-components 때문에 createContext 는 use client에서만 사용할수있다라는 에러인거같은데 AdminLayOut이나 다른 페이지에서도 useContext를 사용하려하면 'use client'를 작성하여도 같은 에러가 나옵니다. 현재 말씀드린 정보로만으로는 에러의 문제점을 찾을순 없을까요?

  • react
  • next.js
  • react-query
  • next-auth
  • msw
밍끼 댓글 1 좋아요 0 조회수 1831

2:34 RQProvider에 "use client"; 로 csr 선언?을 해주신 것 같은데 이런 형식의 구조라면 SSR이나 SSG 적용에는 문제가 없을까요?

미해결

Next + React Query로 SNS 서비스 만들기

안녕하세요 제로초님. 리액트 쿼리를 도입해보려고 할 때 마침 제로초님 강좌가 올라와서 참고하고 있습니다! 근데 제 Nextjs 프로젝트의 데이터가 대부분 ssr이나 ssg로 데이터를 가져오게끔 하려고 하고 있거든요 강의에서 ssr로 데이터를 가져오는데 그전에 RQProvider로 리액트 쿼리를 쓸 범위를 지정해주셨잖아요? 근데 useState를 사용하고 있고, "use client";가 선언되어있는데 그 밑으로 담기는 페이지나 컴포넌트들에 ssr, ssg 적용이 잘 되는지에 대해 궁금해져서 질문을 남기게 되었습니다!! (제로초님 강의와 비슷하게 ssr로 데이터 가져오게 작업해봤을때 csr이 아니라 ssr로 잘 가져오는 거 같기는 한데 어떻게 되는거지?! 계속 궁금하네요..!)

  • react
  • next.js
  • react-query
  • msw
bcm.ianahn 댓글 1 좋아요 0 조회수 951

클라이언트 컴포넌트로 전환하기 1:07초 파일

해결됨

Next + React Query로 SNS 서비스 만들기

안녕하세요 제로초님! 현재 강좌를 따라하면서 진행중인데 깃허브에 들어가보니 @modal 밑에 파일들을 못 찾겠어서요, login.module.css은 https://github.com/ZeroCho/next-app-router-z/blob/master/ch1/src/app/(beforeLogin)/_component/login.module.css 여기있는거 같은데, page.tsx는 어떤 파일에서 보면 될까요?

  • react
  • next.js
  • react-query
  • next-auth
  • msw
호호히히히 댓글 2 좋아요 0 조회수 668

leftSectionWrapper와 rightSectionWrapper 중앙 정렬

해결됨

Next + React Query로 SNS 서비스 만들기

leftSectionWrapper와 rightSectionWrapper를 중앙 정렬시키기 위해 각각에 flex-grow: 1 을 주셨는데container에 margin: 0 auto 주는 것과 동일한건지 궁금합니다!

  • react
  • next.js
  • react-query
  • next-auth
  • msw
  • css
mihyun Lee 댓글 1 좋아요 0 조회수 529

revalidate 질문

해결됨

손에 익는 Next.js - 공식 문서 훑어보기

안녕하세요 선생님 강의 내용중에 revalite 의 방식이 두가지가 있다고 하셨고 그중 하나인 time 방식은 예를들어 10초로 설정하였다면 10초후에 누군가가 요청을하면 첫번째 요청자는 이전 값을 받고 두번째 요청하였을때 새로운 값을 받는거라고 이해하였습니다. 그렇다면 게시판에 적용하였을때 A유저가 새글을 작성하고 다시 게시글 목록페이지로 돌아가면 1번째 요청이 되기때문에 새글이 보이지 않고 새로고침을하면 2번째 요청이 되어서 보이게 되는 걸까요? 그리고 위의 내용이 맞다면 작성후 목록 페이지로 갔을때 본인이 작성했던 새 글이 바로 보이려면 어떻게 해야할까요? 온디맨드도 요청이 있을때 일단 먼저 값을 보여주고 그 다음부터 새 값을 보여주는거니 이건 아닌것같고.. 강의 보다가 좋은 방법이 있는지 궁금하네요 ^^ P.S : 정말 알차고 좋은강의 감사드립니다 선생님! 볼때마다 너무 만족스러운 강의예요!

  • react
  • typescript
  • next.js
  • next.js13
가스라이팅의정석 댓글 1 좋아요 1 조회수 501

MSW오류 및 서버 액션에 대한 질문입니다!

해결됨

Next + React Query로 SNS 서비스 만들기

안녕하세요!‘서버 컴포넌트에서 Server Actions 사용하기’ 섹션을 듣고 질문 2개가 생겼습니다. 강의를 다 듣고 실제로 진행해보니 저의 경우는 redirect('/home') 으로리다이렉션이 진행되지 않습니다 network탭을 보니 애초에 서버로 데이터 전송이 안 된 것 같습니다 (payload에는 제대로 데이터가 전송이 됐고 Headers를 보면 status가 200이 뜨긴 하네요) 그래서 MSW문제인가 싶어서 http://localhost:9090/ 에 접속해보니 에러가 발생하네요 MSW설정 자체가 문제인것 같은데 강의내용을 보고 그대로 따라했는데 어느 부분에서 문제가 발생한지 도저히 모르겠습니다.. 제 코드들을 첨부하겠습니다 // browser.ts import { setupWorker } from 'msw/browser'; import { handlers } from './handlers'; // This configures a Service Worker with the given request handlers. const worker = setupWorker(...handlers); export default worker; // handlers.ts import { http, HttpResponse } from 'msw'; export const handlers = [ http.post(`/api/login`, () => { console.log('로그인'); return HttpResponse.json( { userId: 1, nickname: '제로초', id: 'zerocho', image: '/5Udwvqim.jpg', }, { headers: { 'Set-Cookie': 'connect.sid=msw-cookie;HttpOnly;Path=/', }, }, ); }), http.post(`/api/logout`, () => { console.log('로그아웃'); return new HttpResponse(null, { headers: { 'Set-Cookie': 'connect.sid=;HttpOnly;Path=/;Max-Age=0', }, }); }), http.post('/api/users', async ({ request }) => { console.log('회원가입'); // 403에러 전용 // return HttpResponse.text(JSON.stringify('user_exists'), { // status: 403, // }); // 성공 전용 return HttpResponse.text(JSON.stringify('ok'), { headers: { 'Set-Cookie': 'connect.sid=msw-cookie;HttpOnly;Path=/;Max-Age=0', }, }); }), ]; // http.ts import { createMiddleware } from '@mswjs/http-middleware'; import express from 'express'; import cors from 'cors'; import { handlers } from './handlers'; const app = express(); const port = 9090; // 서버 포트 번호 // 현재 돌아가고 있는 로컬호스트 주소 app.use(cors({ origin: 'http://localhost:3000', optionsSuccessStatus: 200, credentials: true })); app.use(express.json()); app.use(createMiddleware(...handlers)); app.listen(port, () => console.log(`Mock server is running on port: ${port}`)); 정확히 서버액션 이라는 개념이 이해가 가질 않습니다 기존 리액트에서 클릭 이벤트 또는 서브밋 이벤트로 폼을 제출하는 방식이 아니라, 폼의 action을 사용해 서버로 폼의 데이터를 제출하는 것같은데, 이것만 보면 그냥 폼데이터 값으로 백엔드 api를 이용하는거같은데.. .정확한 서버 액션 이라는 그 의미를 잘 모르겠네요… 구글링 해보면 따로 api를 생성할 필요 없이 API를 바로 만들어서사용하는거라고 하는데 여기서는 백엔드 API를 사용하고 있고…혹시 다음 강의에 자세한 설명이 나오는것인가요?너무 헷갈리네요

  • react
  • next.js
  • react-query
  • next-auth
  • msw
kraf 댓글 1 좋아요 0 조회수 1202

섹션3. 날씨 재검증하기 NextRequest 질문입니다.

해결됨

손에 익는 Next.js - 공식 문서 훑어보기

콘솔로그 결과 안녕하세요 선생님, 강의를보고 간단하게 따라해보았는데요 NextRequest 타입의 req를 매개변수로 받아와서 req를 console.log 에 찍어보면 undefined가 뜹니다. 혹시 NextRequest 사용에 조건이 따로 있을까요? req.nextUrl.pathname 으로 url 도 가져와보고 싶고한데 생각처럼 잘 안되네요..

  • react
  • typescript
  • next.js
  • next.js13
가스라이팅의정석 댓글 1 좋아요 1 조회수 363

freeboard_frontend 작업 중 Failed to fetch

해결됨

[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스

freeboard_frontend 폴더에서 댓글 부분 만들려고 yarn dev해서 화면을 확인하려고 하는데 /boards 부분 화면은 뜨는데 글 목록은 하나도 뜨지않고 작성하기를 하려하니 alert 창으로 Failed to fetch 라는 안내가 뜹니다 혹시 뭐가 문제인지 알 수 있을까요?

  • react
  • node.js
  • seo
  • graphql
  • next.js
서나현 댓글 2 좋아요 0 조회수 345

강의 자료 부탁드립니다!

미해결

프로그래밍 시작하기 : 파이썬 입문 (Inflearn Original)

안녕하세요. 강의 자료 요청합니다. elel3418@daum.net 감사합니다!

  • python
댓글 1 좋아요 0 조회수 216

로그인 문제

미해결

Next + React Query로 SNS 서비스 만들기

로그인 테스트 해보려는데 try, catch 부분 둘 다 실행되네요?. 리다이렉트가 안되는거 같아요 새로 고침하면 로그인 상태는 됩니다. 리다이렉트 안되는 이유가 무엇일까요? 'use client'; import style from '@/app/(beforeLogin)/_component/login.module.css'; import { ChangeEventHandler, FormEventHandler, useState } from 'react'; import { useRouter } from 'next/navigation'; import { signIn } from 'next-auth/react'; // 클라이언트에서는 next-auth/react에서 임포트 export default function Page() { const [id, setId] = useState(''); const [password, setPassword] = useState(''); const [message, setMessage] = useState(''); const router = useRouter(); const onSubmit: FormEventHandler<HTMLFormElement> = async (e) => { e.preventDefault(); setMessage(''); try { await signIn('credentials', { username: id, password, redirect: false, }); router.replace('/home'); } catch (error) { console.error(error); setMessage('아이디와 비밀번호가 일치하지 않습니다.'); } }; const onClickClose = () => { router.back(); }; const onChangeId: ChangeEventHandler<HTMLInputElement> = (e) => { setId(e.target.value); }; const onChangePassword: ChangeEventHandler<HTMLInputElement> = (e) => { setPassword(e.target.value); }; return ( <div className={style.modalBackground}> <div className={style.modal}> <div className={style.modalHeader}> <button className={style.closeButton} onClick={onClickClose}> <svg width={24} viewBox='0 0 24 24' aria-hidden='true' className='r-18jsvk2 r-4qtqp9 r-yyyyoo r-z80fyv r-dnmrzs r-bnwqim r-1plcrui r-lrvibr r-19wmn03' > <g> <path d='M10.59 12L4.54 5.96l1.42-1.42L12 10.59l6.04-6.05 1.42 1.42L13.41 12l6.05 6.04-1.42 1.42L12 13.41l-6.04 6.05-1.42-1.42L10.59 12z'></path> </g> </svg> </button> <div>로그인하세요.</div> </div> <form onSubmit={onSubmit}> <div className={style.modalBody}> <div className={style.inputDiv}> <label className={style.inputLabel} htmlFor='id'> 아이디 </label> <input id='id' className={style.input} value={id} onChange={onChangeId} type='text' placeholder='' /> </div> <div className={style.inputDiv}> <label className={style.inputLabel} htmlFor='password'> 비밀번호 </label> <input id='password' className={style.input} value={password} onChange={onChangePassword} type='password' placeholder='' /> </div> </div> <div className={style.message}>{message}</div> <div className={style.modalFooter}> <button className={style.actionButton} disabled={!id && !password}> 로그인하기 </button> </div> </form> </div> </div> ); } 핸들러 부분도 수정했습니다. const User = [ { id: 'elonmusk', nickname: 'Elon Musk', image: '/yRsRRjGO.jpg' }, { id: 'zerohch0', nickname: '제로초', image: '/5Udwvqim.jpg' }, { id: 'dongwook98', nickname: '신동마', password: '1234', image: '/me.jpeg' }, { id: 'leoturtle', nickname: '레오', image: faker.image.avatar() }, ]; const Posts = []; export const handlers = [ http.post('/api/login', () => { console.log('로그인'); return HttpResponse.json(User[2], { headers: { 'Set-Cookie': 'connect.sid=msw-cookie;HttpOnly;Path=/', }, }); }), 추가로 콘솔 에러 메시지 입니다. 이걸 보고 AUTH_URL 도 확인해보았는데 다 잘 적어줬습니다. 또 로그인 하기 전 메인 페이지에서 로그인 버튼 눌러서 로그인 모달이 뜨는 순간 콘솔 탭에 이러한 에러 메시지가 생깁니다. 위 에러 메시지는 검색해서 useEffect(() => { router.replace('/i/flow/login'); }, []); useEffect로 감싸주어서 해결하였습니다.

  • react
  • next.js
  • react-query
  • next-auth
  • msw
욱둥이 댓글 1 좋아요 1 조회수 802

페러렐과 인터셉트 라우팅을 활용한 모달에 대한 질문입니다.

해결됨

Next + React Query로 SNS 서비스 만들기

기존의 모달 방식(제 기준) 은 Context나 recoil과 같은 상태관리 모달로 Provider를 만들어서 isOpen setIsOpen과 같이 사용했는데 이번에 배운 방식도 좋은 방법인 것 같지만, 폴더 구조가 엉망이 되서 가독성이 떨어지는 것 같다는 생각이 들어서 강사님 생각에는 어떤 방식이 어느 상황에서 더 좋을 것 같은지 궁금해서 질문 드려 봅니다.

  • react
  • next.js
  • react-query
  • next-auth
  • msw
리액트 매니아 댓글 1 좋아요 1 조회수 543

github에 올라와 있는 파일중에 module.css파일이 있나요?

해결됨

Next + React Query로 SNS 서비스 만들기

저는 여기서 파일을 zip으로 다운받아서 복사하려고 했는데 https://github.com/ZeroCho/next-app-router-z module.css파일을 찾을 수가 없어서 혹시 어디서 찾아야 할까요?

  • react
  • next.js
  • react-query
  • next-auth
  • msw
리액트 매니아 댓글 1 좋아요 0 조회수 474

메타데이터 관련 질문

해결됨

손에 익는 Next.js - 공식 문서 훑어보기

동적 메타데이터를 적용하려고 합니다. 메타데이터가 위치해야하는곳에 대해서 궁금한데요 generateMetadata 함수는 layout 혹은 page.tsx 에만 위치해야 하나요? page.tsx 안에서 import 한 컴포넌트안에 넣었더니 적용이 안되길래 여쭤봅니다

  • react
  • typescript
  • next.js
  • next.js13
가스라이팅의정석 댓글 1 좋아요 0 조회수 244

타입스크립트 질문

미해결

Next + React Query로 SNS 서비스 만들기

useFormState initialState부분 타입스크립트 에러 질문입니다. message에 string이 와야한다고 에러가 뜨는데 이거를 string | null로 해주는 방법을 잘 모르겠습니다! const initialState: { message: string | null; } = { message: null, }; export default function SignupModal() { const [state, formAction] = useFormState(onSubmit, initialState); const { pending } = useFormStatus(); 일단 이런식으로 빼서 에러 없애긴하였는데 인라인으로는 못하나요?

  • react
  • next.js
  • react-query
  • next-auth
  • msw
욱둥이 댓글 3 좋아요 0 조회수 1162

프론트엔드 세션과 백엔드 세션 / queryClient.getQueryCache에 대한 질문이 있습니다!

해결됨

Next + React Query로 SNS 서비스 만들기

안녕하세요! 제로초님! 항상 강의를 감사히 잘 보고있습니다! 다름이 아니라, 세션에 대한 질문이 있어 글을 올립니다. 첫번째 질문입니다! 현재 클라이언트(브라우저)에서 로그인 요청 시, auth.js를 사용해서 프론트측 세션을 생성하고, 그것을 통해서 클라이언트의 로그인 상태에 대한 분기 기준으로 사용하고 있고, 백엔드에서도 API 허가를 위한 세션을 받아 connect.sid 라는 쿠키를 생성하여 총 2개의 쿠키를 이용하고 있습니다. 제가 궁금한 것은 현재 2개로 나누어진 세션을 백엔드에서 주는 세션으로 생성한 쿠키 1개만 사용해도 되지 않을까? 라는 생각이 들었는데, 각각 따로따로 세션을 생성해서 처리하는 이유가 궁금합니다. 혹시 프론트엔드 입장에서 next-auth (auth.js)가 제공해주는 기능(CSRF, useSession, signin 등의 메서드... )들이 편리해서, 이것을 사용하신것이고 강의에서 언급하신대로 백엔드 세션과 통합하는 과정이 아직 불완전하여 따로 둔 상태로 둔 것이며, 만약 next-auth가 주는 장점이 굳이 없었다면 처음부터 백엔드 세션 1개를 이용해서 로그인 과정을 구현했을 것 이다. 라고 제가 감히 예상을 해도 될까요.. ? 🤔 두번째 질문입니다. [재게시, 답글기능 zustand로 만들어보기] 강의 17분 40초 부근에서 queryClient.getQueryData 보다 getQueryCache를 사용하는게 더 정확하다라고 말씀하셨는데 그 이유가 궁금합니다!

  • react
  • next.js
  • react-query
  • next-auth
  • msw
withkey 댓글 1 좋아요 1 조회수 702

print 출력

미해결

프로그래밍 시작하기 : 파이썬 입문 (Inflearn Original)

선생님처럼 깔끔하게 괄호 안에 있는 부분만 뜨는 게 아니라 저 파란 줄로 길게 뜨는 건 왜 그런 건가요? 어떻게 하면 없앨 수 있나요?

  • python
hjy648012 댓글 2 좋아요 0 조회수 324

패러랠 라우트 질문(로그인 모달 관련)

해결됨

Next + React Query로 SNS 서비스 만들기

로그인모달을 패러랠 라우트 방식으로 구현하는 과정에서 default.tsx 강의 타임라인 0:34에서 app/(beforeLogin)/@modal 폴더에 있던 page.tsx와 login.module.css파일을 복사해서 app/(beforeLogin)/i/flow/login로 디렉터리를 만들어서 거기에다가 page.tsx와 login.module.css파일로 넣으셨는데요. URL이 http://localhost:3000/i/flow/login이면 @modal 하위에도 그 url 경로대로 폴더 구조를 맞춰서 넣어줘야 하는 것이죠? 패러랠방식에 대해서 아직 감이 안잡힙니다. (beforeLogin)폴더 자식으로 @modal폴더와 layout.tsx에 가 있고 laytout.tsx에서 modal을 props로 가져옵니다. 그럼 그 modal이라고 이름지은 것은 같은 뎁스에 있는 "@자기이름"인 @modal을 탐색해서 가져오는건가요? import { ReactNode } from "react"; import styles from "@/app/page.module.css"; type Props = { children: ReactNode; modal: ReactNode; }; export default async function BeforeLoginLayout({ children, modal }: Props) { return ( <div> <div className={styles.container}> {children} {modal} </div> </div> ); }

  • react
  • next.js
  • react-query
  • next-auth
  • msw
gga01075 댓글 1 좋아요 2 조회수 913

이벤트리스너 함수를 지정할 때, 화살표 함수와 그냥 함수의 차이

해결됨

따라하며 배우는 리액트 A-Z[19버전 반영]

안녕하세요. 현재 섹션 3 수강 중인 수강생입니다. todo App을 만들고 있는데, X 버튼 구현하는 부분에서 onClick 이벤트 발생 시 작동하는 함수를 삽입해주는 부분인데요. onClick => {handleClick(data.id)} 이렇게 입력하니 웹페이지가 제대로 동작하지 않고, 아래처럼 화살표 함수로 바꿔주니 정상적으로 동작합니다. <button onClick={() => handleClick(data.id)}> x </button> 찾아보니 함수명으로 넣어주는 경우는 렌더링 시 함수가 바로 실행되고 click 이벤트 발생 시엔 함수의 반환값이 중괄호 안에 들어간다고 하고, 화살표 함수로 넣어줄 경우 의도한대로 click이벤트 발생 시에 함수가 실행된다는 걸 알게됐는데요, 이런 부분은 리액트 동작 원리 상 이렇게 되는거니 그냥 받아들이면 될까요? 아니면 제가 js 문법에 대해 이해가 부족해서 이해가 안가는 걸까요...? 추가적으로, 그렇다면 리액트에서 이벤트리스너 함수를 넣을 때는 무조건 화살표 함수로 넣는게 맞는건가요?

  • react
  • redux
  • tdd
  • typescript
  • next.js
  • 소프트웨어-테스트
김민희 댓글 2 좋아요 0 조회수 701

인터셉팅 라우트 버그?..

미해결

Next + React Query로 SNS 서비스 만들기

게시하기 버튼 클릭하면 인터셉팅 라우트가 되지 않네요 ㅜ 회원가입, 로그인에서는 인터셉팅 라우트가 잘 됬었는데 왜이러는걸까요?.. 아직 넥스트가 불안정 한건지.. 검색해도 잘 안나오네요..

  • react
  • next.js
  • react-query
  • next-auth
  • msw
욱둥이 댓글 1 좋아요 0 조회수 671

인기 태그

인프런 TOP Writers

주간 인기글