무료
다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 미해결처음 만난 리액트(React)
styled-components
chapter 15 실습에서 막힙니다.styled-components를 @latest 붙여서 다운받았는데도 실행이 안됩니다.그냥 빈 하얀 화면만 뜹니다...다른 챕터는 확인해보니까 다 되던데, 왜 styled-components 실습만 왜 안될까요?Blocks.jsx 파일 코드import styled from "styled-components"; const Wrapper = styled.div` padding: 1rem; display: flex; flex-direction: row; align-items: flex-start; justify-content: flex-start; background-color: lightgrey; `; const Block = styled.div` padding: ${(props) => props.padding}; border: 1px solid black; border-radius: 1rem; background-color: ${(props) => props.backgroundColor}; color: white; font-size: 2rem; text-align: center; `; const blockItems = [ { label: "1", padding: "1rem", backgroundColor: "red", }, { label: "2", padding: "3rem", backgroundColor: "green", }, { label: "3", padding: "2rem", backgroundColor: "blue", }, ]; function Blocks(props) { return ( <Wrapper> {blockItems.map((blockItem) => { return ( <Block padding={blockItem.padding} backgroundColor={blockItem.backgroundColor} > {blockItem.label} </Block> ); })} </Wrapper> ); } export default Blocks; index.js 파일 코드import React from "react"; import ReactDOM from "react-dom/client"; import "./index.css"; import App from "./App"; import reportWebVitals from "./reportWebVitals"; // import Library from "./chapter_03/Library"; // import Clock from "./chapter_04/Clock"; // import CommentList from "./chapter_05/CommentList"; // import NotificationList from "./chapter_06/NotificationList"; // import Accomodate from "./chapter_07/Accommodate"; // import ConfirmButton from "./chapter_08/ConfirmButton"; // import LandingPage from "./chapter_09/LandingPage"; // import AttendanceBook from "./chapter_10/AttendanceBook"; // import SignUp from "./chapter_11/SignUp"; // import Calculator from "./chapter_12/Calculator"; // import ProfileCard from "./chapter_13/ProfileCard"; // import DarkOrLight from "./chapter_14/DarkOrLight"; import Blocks from "./chapter_15/Blocks"; const root = ReactDOM.createRoot(document.getElementById("root")); root.render( <React.StrictMode> <Blocks /> </React.StrictMode> ); // If you want to start measuring performance in your app, pass a function // to log results (for example: reportWebVitals(console.log)) // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals reportWebVitals();빈 하얀 화면에서 F12 눌러서 오류 확인해보니까 이렇게 뜹니다.Warning: Each child in a list should have a unique "key" prop.Check the render method of Blocks. See https://reactjs.org/link/warning-keys for more information. at O (http://localhost:3000/static/js/bundle.js:43804:6) at BlocksprintWarning @ react-jsx-dev-runtime.development.js:872react.development.js:209 Warning: 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 Hooks3. You might have more than one copy of React in the same appSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.printWarning @ react.development.js:209react.development.js:1618 Uncaught TypeError: Cannot read properties of null (reading 'useContext') at Object.useContext (react.development.js:1618:1) at StyledComponent.ts:124:1 at O (StyledComponent.ts:190:1) at renderWithHooks (react-dom.development.js:16305:1) at updateForwardRef (react-dom.development.js:19226:1) at beginWork (react-dom.development.js:21636:1) at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1) at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1) at invokeGuardedCallback (react-dom.development.js:4277:1) at beginWork$1 (react-dom.development.js:27451:1)2react.development.js:209 Warning: 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 Hooks3. You might have more than one copy of React in the same appSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.printWarning @ react.development.js:209react.development.js:1618 Uncaught TypeError: Cannot read properties of null (reading 'useContext') at Object.useContext (react.development.js:1618:1) at StyledComponent.ts:124:1 at O (StyledComponent.ts:190:1) at renderWithHooks (react-dom.development.js:16305:1) at updateForwardRef (react-dom.development.js:19226:1) at beginWork (react-dom.development.js:21636:1) at HTMLUnknownElement.callCallback (react-dom.development.js:4164:1) at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:1) at invokeGuardedCallback (react-dom.development.js:4277:1) at beginWork$1 (react-dom.development.js:27451:1)react-dom.development.js:18687 The above error occurred in the <styled.div> component: at O (http://localhost:3000/static/js/bundle.js:43804:6) at BlocksConsider adding an error boundary to your tree to customize error handling behavior.Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.logCapturedError @ react-dom.development.js:18687react-dom.development.js:26923 Uncaught TypeError: Cannot read properties of null (reading 'useContext') at Object.useContext (react.development.js:1618:1) at StyledComponent.ts:124:1 at O (StyledComponent.ts:190:1) at renderWithHooks (react-dom.development.js:16305:1) at updateForwardRef (react-dom.development.js:19226:1) at beginWork (react-dom.development.js:21636:1) at beginWork$1 (react-dom.development.js:27426:1) at performUnitOfWork (react-dom.development.js:26557:1) at workLoopSync (react-dom.development.js:26466:1) at renderRootSync (react-dom.development.js:26434:1) 뭐가 문제일까요?
- 미해결처음 만난 리액트(React)
npm start 하고 localhost:3000으로 접속할때 로드오류
npm start 하고 localhost:3000으로 접속이 되었고, 리액트 로딩창만 나오고 다음창이 로드가 안됩니다. 터미널에서도 successfully 뜨고 코드도 오류가 없습니다. 왜 로딩이안될까요 ? 단순 컴퓨터문제일까요?
- 미해결처음 만난 리액트(React)
[미니블로그]
미니블로그 다 따라하고 실행하면 에러가 발생합니다.어떤 문제일까요?
- 미해결처음 만난 리액트(React)
css 질문
안녕하세요! 소플님 실습을 하는 중인데 그림에 해당 부분의 간격이 안생기는데 저 css는 어디 컴포넌트에서 주신걸까요? 소스를 한참 비교해봤는데 모르겠어서 문의 드립니다!!
- 미해결처음 만난 리액트(React)
12 강 props.onTemoeratureChange() 함수 질문
props.onTemperatureChange()함수는 정의해 놓지 않았는데 onTemperatureChange()함수는 어디에서 제공해준 함수 인가요?
- 미해결처음 만난 리액트(React)
12강 props.onTemperatureChange() 함수 질문
setTemperature() 함수 대신 props.onTemperatureChange() 함수를 사용 했는데~요onTemperatureChange() 함수는 state에 없는데 이 함수는 어디에서 제공 해주는지 잘 모르겠습니다
- 미해결처음 만난 리액트(React)
코드 질문
위에 컴포넌트에서 최상위의 컴포넌트는 상위에서 받을 props가 없어서 안적어도 될 것 같은데 적는데는 다른 의미가 있나요?
- 미해결처음 만난 리액트(React)
npm install --save react-router-dom 설치 질문
해당 코드를 터미널에서 작성했는데 설치가 되지 않습니다.. 무슨 문제일까요...
- 미해결처음 만난 리액트(React)
false expression
Inline If에서 false expression을 사용하면 뒤에 내용은 평가되지 않지만, false expression의 결과 값이 그대로 리턴되기 때문에 주의 해야 한다 이렇게 말씀하셨는데 그러면 하단의 흰색 박스에 조건이 만족하지 않을 경우에도 결과 값을 그대로 리턴하나요..?
- 미해결처음 만난 리액트(React)
state.notifications 배열에 push가 가능한지 질문드리겠습니다.
const { notifications } = this.state; const index = notifications.length; notifications.push(reservedNotifications[index]); this.setState({ notifications: notifications })위 코드에서 state.notifications 배열에 바로 push를 해서 setState를 해줬는데지난 강의에서는 state에 있는 배열 또는 객체를 직접 수정하지 않고 복사해서newNotifications = [...notifications] 처럼새로 할당 한 다음 setState를 해준다고 봤던 부분이 있어서 어떤 경우에는 직접 state배열에 push가 가능한지 질문 드려도 괜찮을까요 강의 잘 보고 있습니다. 감사합니다!
- 미해결처음 만난 리액트(React)
렌더링 관련 질문
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 안녕하세요 소플님 실습을 따라 해보았는데 하나의 useEffect는 컴포넌트가 렌더링 될 때마다 콘솔이 찍히고 하나의 useEffect는 count값이 변경될 때마다 찍힌다는 것까지는 이해했습니다. 근데 마지막 최대 인원을 수용하는 10명까지 수용을 하고는 버튼 컴포넌트가 isFull: true로 찍히고 컴포넌트가 렌더링 되지 않아서 useEffect 콘솔과 isFull: true 이 안 찍혀야 하는 것 아닌가요? 왜 이렇게 찍히는지 이해가 안됩니다,,ㅠㅠ
- 해결됨처음 만난 리액트(React)
최종변환?
jsx강의 에서는 jsx는 내부적으로 html/xml코드를 자바스크립트로 변환하는 과정을 거치게 된다. 그래서 최종적으로는 자바스크립트 코드로 나오게 된다. 이렇게 말씀해주시고 jsx코드를 자바스크립트 코드로 변환하게 해주는 것이 react.createElement라고 하셨는데, 여기 강의 에서는 5분 35초 부근에 react.createElement 내부에 리액트 컴포넌트를 적어도 되고 모든 리액트 컴포넌트는 최종적으로는 html 태그를 사용하게 돼있다라고 하셨습니다. react.createElement를 통해서 최종적으로 자바스크립트가 된다는건가요? 아니면 html 코드가 된다는건가요,,?ㅠㅠ
- 미해결처음 만난 리액트(React)
(실습) create-react-app 자꾸 오류가 나요,,
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.create-react-app 을 하면 자꾸 이런 오류가 떠서 실습을 못하고 있는데 뭐가 문제일까요..?
- 해결됨처음 만난 리액트(React)
componentDidUpdate 관련 질문
3개의 배열 메세지 모두 동일하게 map함수로 돌리고 화면에 출력하였는데, 1 didupdate call만 두 번 콘솔에 찍히고 3번 didupdate call는 콘솔에 안 찍히는 이유가 궁금합니다
- 미해결처음 만난 리액트(React)
chapter07 Custom Hook에서 ServerAPI 에러
chapter07 Custom Hook에서 ServerAPI 에러가 나오는데 해결을 못하여 도움 요청합니다 에러
- 미해결처음 만난 리액트(React)
코드가 맞는 것 같은데 어떤 점이 문제인지 모르겠네요..
이렇게 코드를 짰는데..맞는 것 같은데...이렇게 뜹니다...
- 미해결처음 만난 리액트(React)
시계 만들기 실습 관련 질문 있습니다.
선생님께서 보여주신 React App 시계 만들기 실습 화면에는 "오후 6:35:38" 처럼 시간 부분에 반짝거리는 효과가 나오는데, 제 화면에서는 다음과 같이 div 부분에 효과가 나오는데, 이게 18 버전이라서 다른건가요? 그게 아니라면 어떤 이유 때문에 다르게 나오는건지 궁금합니다.
- 미해결처음 만난 리액트(React)
12강 실습 (섭씨 화씨)
안녕하세요 12강 실습코드를 그대로 작성했는데 섭씨온도를 적었을때 화씨온도로 자동으로 변환되어 나타나지 않습니다. 화씨온도를 먼저 적었을때도 마찬가지고요. 코드 한번 봐주실 수 있나요? 감사합니다. Calculatorimport React, {useState} from "react"; import TemperatureInput from "./Temperatureinput"; function BoilingVerdict(props){ if(props.celsius >= 100){ return <p>물이 끓습니다.</p>; } return <p>물이 끓지 않습니다.</p>; } function toCelsius(fahrenheit){ return ((fahrenheit-32)*5)/9; } function toFahrenheit(celsius){ return (celsius*9)/5+32; } function tryConvert(temperature,convert){ const input = parseFloat(temperature); if(Number.isNaN(input)){ return ""; } const output = convert(input); const rounded = Math.round(output*1000)/1000; return rounded.toString(); } function Calculator(props){ const [temperature, setTemperature] = useState(""); const[scale,setScale]=useState("c"); const handleCelsiusChange = (temperature) => { setTemperature(temperature); setScale("c"); }; const handleFahrenheitChange = (temperature) => { setTemperature(temperature); setScale("f"); }; const celsius = scale === "f" ? tryConvert(temperature, toCelsius):temperature; const fahrenheit = scale === "c" ? tryConvert(temperature, toFahrenheit):temperature; return ( <div> <TemperatureInput scale="c" temperatrue = {celsius} onTemperatureChange={handleCelsiusChange}/> <TemperatureInput scale="f" temperatrue = {fahrenheit} onTemperatureChange={handleFahrenheitChange}/> <BoilingVerdict celsius={parseFloat(celsius)} /> </div> ); } export default Calculator;Temperatureinputconst scaleNames = { c:'섭씨', f:'화씨', }; function TemperatureInput(props){ const handleChange = (event) => { props.onTemperatureChange(event.target.value); }; return ( <fieldset> <legend> 온도를 입력해주세요(단위:{scaleNames[props.scale]}); </legend> <input value={props.temperature} onChange={handleChange} /> </fieldset> ); } export default TemperatureInput;
- 미해결처음 만난 리액트(React)
styled-components 설치 문제
module를 지웠다가 깔아봐도 계속 이 오류가 뜨네요.,..
- 미해결처음 만난 리액트(React)
11강 실행시 페이지 내용에 문제가 있네요
결과가 이렇게 나오는데 뭐가 잘못된걸까요?