자식 컴포넌트에서 부모 컴포넌트로
-
React 자식 컴포넌트에서 부모로 데이터 보내기Programming/React 2020. 5. 9. 10:32
앞서 포스팅한 React input 상태관리를 그대로 이어서 자식 컴포넌트에서 부모 컴포넌트로 데이터를 보내는 것을 복습겸 정리하도록 하겠습니다. App.js import React, { Component } from 'react'; import JoinForm from './components/JoinForm'; import './App.css'; class App extends Component { id = 0; state = { memberInfo: [], }; handleCreate = (data) => { const { memberInfo } = this.state; this.setState({ memberInfo: memberInfo.concat({ ...data, id: this.id++, ..