인프런 커뮤니티 질문&답변

yjym33님의 프로필 이미지

작성한 질문수

한 입 크기로 잘라먹는 Next.js(15+)

7.4) 리뷰 재검증 구현하기

오류 질문

해결된 질문

24.09.30 14:17 작성

·

52

0

안녕하세요 강사님 강의를 보면서 따라하는 도중에

오타가 없는거같은데 오류가 발생해서 질문드립니다.

value값을 onChange 있는곳에 써야하는데 쓰지 않아서 발생하는 문제인거 같은데 해당 오류 때문에 TextArea도 정상적으로 css부분이 적용되지 않습니다.

image.png


답변 3

0

이정환 Winterlood님의 프로필 이미지
이정환 Winterlood
지식공유자

2024. 09. 30. 15:26

안녕하세요 이정환입니다.

우선 해당 경고 메세지는 수정을 권고하는 경고 수준의 메세지입니다 (자세히 읽어보시면 Error가 아닌 Warning 이라고 표시되어 있어요) 따라서 오류가 발생한 것은 아니며 이로 인해 CSS 적용이 되지 않거나 하지는 않습니다. CSS는 다른 이슈로 인해 적용되지 않았을 것 같아요

이 경고 메세지가 발생하는 이유는 value Props는 전달해줬으면서 onChange는 전달하지 않아 폼이 수정 불가능 한 상태가 되었을 때 발생합니다. 이럴 경우 웹 브라우저는 해당 폼이나 인풋태그에 readOnly 속성을 추가하여 읽기전용 폼으로 만들것을 권장하고 있습니다. 따라서 경고 메세지를 없애시려면 에러 메세지에 나와있는대로 readOnly 프로퍼티를 추가해주시면 됩니다.

강의에서는 기능 동작에 영향을 주는 오류는 아닌 단순 경고이기에 명확히 짚고 넘어가지는 않았는데요 수강하시는 입장에서는 당황스러우실 수 있을 것 같습니다. 불편함을 드렸다면 죄송합니다 🙇‍♂

조만간 동일한 오해가 반복되지 않도록 별도 메세지를 추가해놓거나 영상을 일부 수정해두겠습니다 😃

0

yjym33님의 프로필 이미지
yjym33
질문자

2024. 09. 30. 14:25

혹시 몰라서 이미지 말고 코드 자체도 남겼습니다.

Warning: You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.

at input

at form

at section

at div

at InnerLayoutRouter (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:246:11)

at RedirectErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/redirect-boundary.js:73:9)

at RedirectBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/redirect-boundary.js:81:11)

at NotFoundBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/not-found-boundary.js:84:11)

at LoadingBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:350:11)

at ErrorBoundaryHandler (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/error-boundary.js:112:9)

at ErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/error-boundary.js:158:11)

at InnerScrollAndFocusHandler (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:157:9)

at ScrollAndFocusHandler (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:232:11)

at RenderFromTemplateContext (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/render-from-template-context.js:16:44)

at Lazy

at OuterLayoutRouter (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:370:11)

at Lazy

at InnerLayoutRouter (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:246:11)

at RedirectErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/redirect-boundary.js:73:9)

at RedirectBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/redirect-boundary.js:81:11)

at NotFoundBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/not-found-boundary.js:84:11)

at LoadingBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:350:11)

at ErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/error-boundary.js:158:11)

at InnerScrollAndFocusHandler (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:157:9)

at ScrollAndFocusHandler (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:232:11)

at RenderFromTemplateContext (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/render-from-template-context.js:16:44)

at Lazy

at OuterLayoutRouter (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:370:11)

at Lazy

at InnerLayoutRouter (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:246:11)

at RedirectErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/redirect-boundary.js:73:9)

at RedirectBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/redirect-boundary.js:81:11)

at NotFoundErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/not-found-boundary.js:76:9)

at NotFoundBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/not-found-boundary.js:84:11)

at LoadingBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:350:11)

at ErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/error-boundary.js:158:11)

at InnerScrollAndFocusHandler (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:157:9)

at ScrollAndFocusHandler (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:232:11)

at RenderFromTemplateContext (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/render-from-template-context.js:16:44)

at Lazy

at OuterLayoutRouter (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/layout-router.js:370:11)

at Lazy

at main

at div

at body

at html

at RedirectErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/redirect-boundary.js:73:9)

at RedirectBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/redirect-boundary.js:81:11)

at ReactDevOverlay (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/react-dev-overlay/app/ReactDevOverlay.js:87:9)

at HotReload (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/react-dev-overlay/app/hot-reloader-client.js:322:11)

at Router (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/app-router.js:202:11)

at ErrorBoundaryHandler (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/error-boundary.js:112:9)

at ErrorBoundary (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/error-boundary.js:158:11)

at AppRouter (webpack-internal:///(ssr)/./node_modules/next/dist/client/components/app-router.js:573:13)

at Lazy

at r3 (/Users/gim-yeongjin/Downloads/Personal/Study/OnlineClasses/Web/LeeJungHwan/onebite-next/section07/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:39:20108)

at ServerInsertedHTMLProvider (/Users/gim-yeongjin/Downloads/Personal/Study/OnlineClasses/Web/LeeJungHwan/onebite-next/section07/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:39:25931)

 

0

인프런 AI 인턴님의 프로필 이미지

2024. 09. 30. 14:21

안녕하세요, 인프런 AI 인턴입니다. yjym33님의 질문에 대해 답변드립니다.

현재 질문하신 문제는 “React에서 form field의 value 속성에 onChange 핸들러가 제공되지 않아 발생하는 경고“와 관련있습니다. 여러분이 제공하신 이미지와 내용을 바탕으로, 이 문제는 value 속성을 가진 input이나 textarea 요소가 onChange 핸들러를 갖고 있지 않아서 발생한 것으로 보입니다.

React에서는 input 요소에 value 속성을 지정할 경우 사용자 입력으로 인해 value가 변경될 때마다 이를 반영할 수 있는 onChange 이벤트 핸들러도 함께 제공되어야 합니다. 그렇지 않을 경우, input 필드는 읽기 전용 상태가 되어 사용자 입력을 받아들이지 않게 됩니다.

이와 유사한 문제를 다뤘던 이전 질문과 답변들이 있어 제공해드립니다. 이를 참고하여 문제를 해결해 보세요:

  1. value 오류 문의

    • 이 질문에서는 React 컴포넌트에서 useInput 훅을 사용하는 동안 발생한 valueonChange 관련 문제를 다루고 있습니다.
    • 이미지 URL 참고
  2. input 속성 및 state 관리 관련 문제 해결하기

    • 이 질문에서는 input 상태 관리에 대해 자세히 설명하며, valueonChange 속성을 올바르게 다루는 방법에 대해 논의하고 있습니다.

만약 이러한 사례들이 문제 해결에 도움이 되지 않는다면, 해당 부분의 코드를 공유해주시면 더욱 구체적으로 도움을 드릴 수 있을 것 같습니다.

저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다.
현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏
추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.

yjym33님의 프로필 이미지

작성한 질문수

질문하기