1. 인자값 전달하기
function Food(props){
{fav} = props; //fav를 props.fav로 선언하는거임
retrun <h1> i like {fav} </h1>; }
}
function Food({name, picture}){
return(
<h1> i like {name}</h1>
<img src={picture} />
)
}
<Food name={dish.name} picture = {dish.image} // 이렇게 호출하면됨
2.함수형 컴포넌트 & 클래스형 컴포넌트
//함수형 컴포넌트
import React from "react";
function App(){
const name = 'react';
retrun <div classname="react>{name}</div>;
}
//클래스형 컴포넌트
import React, {Component} from 'react'
class App extends Component{
render(){
const name = 'react;
return <div classname="react>{name}</div>;
}
}
//특징 : render가 있음
'일상 > React' 카테고리의 다른 글
React 공부 (with nico 4장) (0) | 2021.01.08 |
---|---|
React 공부 (with nico 3장) (0) | 2021.01.07 |
React 공부 (with nico 2장) (0) | 2021.01.07 |
React 공부 (with nico 1장) (0) | 2021.01.06 |
React 공부 (with reactjs.org 2) (0) | 2021.01.05 |