DevJong12

Redux활용시 createStore Deprecated 본문

Front/React

Redux활용시 createStore Deprecated

Jong12 2023. 4. 4. 11:00
728x90

생활코딩 강의를 들으면서 react-redux를 따라 해보고 있었는데, Store를 생성하려 할 대 @deprecated 선언이 되어있어, 기능상 문제가 있는 것인가 하여, 주석 docs를 보고 알게 되었다.

 

redux의 경우 기본 redux를 import하고 있었으며 Redux Tool Kit을 활용한 store생성이 아니다.

 

먼저 첫번째로 확인한 것은,  Redux Github에서 확인을 하였으며, https://github.com/reduxjs/redux/releases 에서 확인이 가능하다.

 

22. 04. 19에 남긴 v4.2.0 버전의 Tag로, 하단의 버전에서 작업을 진행한 것으로 보인다...


문제 요약

 

WE ARE NOT GOING TO ACTUALLY REMOVE THE createStore API, AND ALL YOUR EXISTING CODE WILL STILL CONTINUE TO WORK AS-IS!

Redux팀에서는 사실상 createStore API를 제거할 예정이 없으며, 기존 코드는 정상적으로 작동할 것이다.


Why deprecated?

문서 내용은 다음과 같았다.

Unfortunately, many tutorials are still showing legacy "hand-written" Redux patterns, which result in a much worse experience for users. New learners going through a bootcamp or an outdated Udemy course just follow the examples they're being shown, don't know that RTK is the better and recommended approach, and don't even think to look at our docs.

Given that, the goal is to provide them with a visual indicator in their editor, like createStore . When users hover over the createStore import or function call, the doc tooltip recommends using configureStore from RTK instead, and points them to that docs page. We hope that new learners will see the strikethrough, read the tooltip, read the docs page, learn about RTK, and begin using it.

번역을 해보자면, 많은 부트캠프, Udemy영상 강의 등의 예시에서는 기존의 Redux패턴을 보여주는 경우가 많다.

RTK가 더 낫고 권장되는 방법이라는 것을 알지 못하며, Redux팀의 문서를 볼 생각을 하지 않는다. 그렇기 때문에 기존에 사용하던 createStore를 deprecated하여 시각적인 효과를 줘서 자신들의 Docs를 보도록 유도를 하여, 새로운 학습자들이 RTK를 배우고 사용하는것을 원하여서 진행 하였다는 내용이다.

 

그와 함께 강조한 문장도 다음과 같다.

Again, no broken code, and no runtime warning

손상된 코드도 없고 실행에 문제도 없다는 것이다.


How to don't see @deprecated

  • Redux Toolkit의 configureStore를 활용한다.
  • redux내부의 createStore를 대신하여 legacy_createStore를 활용한다
    • `import {legacy_createStore as createStore} from 'redux'` 로 선언하는 것을 의미한다.
  • deprecated를 무시한다.

 

마지막 권장방법이 무시하라는 것인데 해당 토픽에서는 deprecated를 '보지 않도록 하는 방법' 이기 떄문에 나도 deprecated를 걸어놓았다. ㅋㅋ;;;

 

 

 

그냥 쓰라고 하니까 좀 싱겁긴하다.

 

 

 

728x90
Comments