Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- HTML #CSS
- BOJ
- optional chanining
- firebase
- Python #Baekjoon
- Default parameter
- es6
- es11
- 카카오맵 api
- react
- HTML
- React #Hooks
- Python #CodeUp
- Hooks
- Nullish Coalescing Operator
- React Kakao map
- Python
- 카카오맵
- JavaScript
- Redux
- css #html
- CSS
- Next
- spread operation
- 프로그래머스
- nextjs
- Template literals
Archives
- Today
- Total
거북이개발자
[Redux] Redux이용한 CRUD구현(Delete) 본문
0. 배경
![]() |
![]() |
위의 사진처럼 각각의 성분을 읽고, 만들고, 지울 수 있는 기능을 Redux를 이용해서 만들 생각이다.
1.
<li><input onclick="
store.dispatch({
type:'DELETE'
});
" type="button" value="delete"></li>
delete버튼 클릭스 dispatch로 type을 변경해준다.
else if(action.type === 'DELETE'){
var newContents = [];
var i = 0;
while(i < state.contents.length){
if(state.selcted_id !== state.contents[i].id){
newContents.push(
state.contents[i]
);
}
i = i + 1;
}
newState = Object.assign({},state, {
contents:newContents,
mode:'welcome'
})
}
reducer 함수 내의 코드이다.
newContents에 선택된 값이 아닌 콘텐츠를 넣어준 뒤
newState에 newContents를 넣은 뒤 리턴해준다.
'Redux' 카테고리의 다른 글
[Redux] Pure Redux 이용한 To-Do List 만들기 (0) | 2021.02.22 |
---|---|
[Redux] Redux기초 프로그래밍 (0) | 2021.02.21 |
[Redux] Redux이용한 CRUD구현(Create) (0) | 2021.02.09 |
[Redux] Redux이용한 CRUD구현(Read) (0) | 2021.02.09 |
[Redux] Redux의 장점 (0) | 2021.02.09 |
Comments