Redux
Redux is a predictable state container for JavaScript Applications.
- Redux is not tied to React (can be used with React, Angular, Vue or even vanilla JS).
- Redux is a library for JavaScript apps.
- Redux stores and manage the application state (state of an app is the state represented by all the individual components off the app).
- In Redux, all state transitions are explicit and it is possible to keep track of them.
React + Redux
With Redux, the state is contained outside the components.
- A라는 컴포넌트가 State 변경을 원한다.
- A는 이를 state container에 알린다.
- state container는 state를 업데이트 하여 필요한 컴포넌트(A+ α )에만 전달한다.
Redux가 반드시 필요한가?
React Context, 그리고 useContext + useReducer로 리덕스 기능을 거의 비슷하게 구현할 수는 있다. 그러나 리덕스가 제공하는 환경을 완전히 대체하지는 못한다.
React-Redux
React는 UI 라이브러리이고, Redux는 State Management 라이브러리이다.
둘은 서로 다른 라이브러리므로, React에서 직접 Redux를 사용하는 방식은 조금 까다롭다. 이로 인해 official Redux UI binding 라이브러리인 React-Redux
패키지가 출시되었다. 이 패키지는 리액트 앱을 리덕스와 연결하는 몇 가지 함수를 제공한다.
결론적으로 React와 Redux를 함께 사용하려면 React-Redux 패키지를 사용해야 한다.
🔗 React Redux Tutorials - 1 - Introduction