React 오류 01
본문 바로가기

컴퓨터공부/React

React 오류 01

by Life & study 2023. 5. 16.
반응형

React 오류 01 코드에 대한 이해

import React,{Component} from "react";
import './App.css';
import {forwardRef} from "react";
import {render} from "react-dom";
/*function App()*/
class App extends Component{
  render () {
      return<header>
          <div className="App">
          Hello,React!;
      </div>
      </header>
  }
}

export default App;

 

import React,{Component} from "react";
import './App.css';
import {forwardRef} from "react";
import {render} from "react-dom";
/*function App()*/
class App extends Component{
  render () {
      return
      <header>
          <div className="App">
          Hello,React!;
      </div>
      </header>
  }
}

export default App;

 

두개의 코드는 얼핏 보면 똑같튼데 왜 한줄 띄엇다고 오류가 날까에 대해서 고민중이다.

WARNING in [eslint]
src\App.js
  Line 3:9:  'forwardRef' is defined but never used  no-unused-vars
  Line 4:9:  'render' is defined but never used      no-unused-vars
  Line 9:7:  Unreachable code                        no-unreachable

webpack compiled with 1 warning

오류해결

문제는 

 

import React,{Component} from "react";
import './App.css';
import {forwardRef} from "react";
import {render} from "react-dom";
/*function App()*/
class App extends Component{
  render () {
      return(
      <header>
          <div className="App">
          Hello,React!;
      </div>
      </header>
      )
  }
}

export default App;

 

return에 (

 (코드를 작성)

)

을 해야됫다.

 

 

반응형

댓글