일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- PYTHON
- 다이나믹프로그래밍
- 파이썬
- java #자바 #동빈나
- react #리액트 #동빈나 #나동빈 #유튜브강의
- 다익스트라
- css #웹 #생활코딩
- BFS
- 자바 #java
- 알고리즘
- 백트랙킹
- dp
- 백준 #파이썬 #알고리즘 #코딩테스트
- react #리액트 #동빈나
- Dijkstra
- 백준
- java #자바 #생활코딩
- 프로그래머스 #파이썬 #코딩테스트 #알고리즘
- 투포인터
- 재귀
- css #생활코딩 #웹
- 백준 #알고리즘 #파이썬 #코딩테스트
- 프로그래머스
- java #자바
- DFS
- 프로그래머스 #파이썬 #알고리즘 #코딩테스트
- 코딩테스트
- 파이썬 #알고리즘 #코딩테스트 #프로그래머스
- java #자바 #나동빈
- 파이썬 #백준 #알고리즘 #코딩테스트
Archives
- Today
- Total
커리까지
[동빈나] 14강 - 부모 컴포넌트의 상태(State) 변경을 통한 고객 정보 갱신 본문
728x90
SMALL
- 필요한 부분만 새로고침 하도록 해야함
- 부모컴포넌트에서 자식에게 전달
class App extends Component {
constructor(props) {
super(props);
this.state = {
customers: '',
completed: 0,
searchKeyword: ''
}
}
stateRefresh = () => {
this.setState({
customers: '',
completed: 0,
searchKeyword: ''
});
this.callApi()
.then(res => this.setState({customers: res}))
.catch(err => console.log(err));
}
- state를 초기화 해준다.
<CustomerAdd stateRefresh={this.stateRefresh}/>
- pros 자체를 넘겨준다.
handleFormSubmit = (e) => {
e.preventDefault()
this.addCustomer()
.then((response) => {
console.log(response.data);
this.props.stateRefresh();
})
this.setState({
file: null,
userName: '',
birthday: '',
gender: '',
job: '',
fileName: '',
open: false
})
}
응답을 받고 나서 Refresh를 실행해주도록 변경
그러면 비동기로 새로고침 됨
고객데이터가 많으면 별로 좋지 않음
728x90
LIST
'react' 카테고리의 다른 글
[동빈나] 16강 - Material UI 모달(Modal) 디자인 구현하기 (0) | 2021.07.04 |
---|---|
[동빈나] 15강 - 고객(Customer) 정보 삭제 기능 구현하기 (0) | 2021.07.04 |
[동빈나] 13강 - Node.js Express에서 파일 업로드 요청 처리 및 DB에 데이터 삽입 (0) | 2021.07.03 |
[동빈나] 12강 - 고객 추가 양식(Form) 구현 및 이벤트 핸들링 (0) | 2021.07.02 |
concurrently --kill-others-on-fail "yarn sever" "yarn client" 'concurrently'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다. (0) | 2021.06.27 |