전체 글105 [React 에러] Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. client.jsx에서 다른 함수를 부르는 상황이었다. react에서는 다른 함수를 불러올 수 있는 방법이 import 와 require이 있다. client.jsx에서는 require로 다른 함수를 부르고 그 함수에서는 import 로 react 등을 불러왔더니 저런 에러가 발생했다. 그래서 require하나로 통일시켰더니 해결되었다. 2020. 11. 12. react 에서 export 하기 변수/class , import /require 마지막 부분에 변수를 export 할 수도 있고 class나 const hook을 export 할 수도 있다. 이때 1. 변수 export const hello = 'hello'; - 많이 쓸 수 있다 여러 변수를 내보낼 수 있다. - import 시 import {hello} 다음과 같이 {} 로 묶어서 불러온다. 2. class, 함수 등 export default ClassNameHello; - 하나만 내보낼 수 있다. - import 시 import ClassNameHello 로 불러온다. import 와 require 1. import 시 import React, {Component} from 'react'; 2. require const React = require('react'); const.. 2020. 11. 11. React hooks의 setstate 함수가 아닌 hooks를 만들어서 사용할 때 원래 class에서 사용했던 setState를 사용하고 싶을 수 있다. setState가 호출되면 class 의 render()가 다시 실행되는 효과가 있다. 이걸 hook에서 사용하고자 하면 const Hooks = () => { const [first, setFirst] = React.useState(Math.ceil(Math.random() * 9)); const onSubmitForm = (e) => { e.preventDefault(); setFirst(Math.ceil(Math.random() * 9)); }; return ( {first} 입력 ); } 이렇게 작성될 수 있다 setState대신에 setFirst를 호출함으로써 Hooks 전체를 새.. 2020. 11. 11. [React 에러] TypeError: Cannot read property 'tap' of undefined npm ruv dev를 했는데 TypeError: Cannot read property 'tap' of undefined 다음과 같은 에러가 났다. webpack이랑 next의 버전이 맞지 않아 생기는 에러였다. webpack을 삭제해주고 npm uninstall webpack 낮은 버전으로 다시 설치해줬다. npm install webpack@4.20.2 2020. 11. 10. 이전 1 ··· 18 19 20 21 22 23 24 ··· 27 다음