Q, createStore 취소선 왜 그어지나?

moontag·2022년 7월 6일
2

Redux

목록 보기
3/4

Store (전역 상태 저장소)의 사용법은 아래와 같다

import { createStore } from 'redux';

const store = createStore(rootReducer);



Q, createStore 취소선 왜 그어지나?

하지만 아래와 같이 코드를 입력하면 createStore 취소선 밑줄이 생기는 것을 볼 수 있다.

createStore에 마우스 호버 시 @deprecated 표시되어있다.
권장되진 않지만 사용을 금지하지는 않는다는 의미다.
호버 시 안내하는 링크 - Why Redux Toolkit is How To Use Redux Today


취소선 그어진 이유

: createStore 밑줄 그어진것은, @reduxjs/toolkit의 권장사용을 유도하기 위해서

취소선 없애는 방법

  1. Redux Toolkit으로 전환하고 configureStore

  2. 그냥 취소선 무시하기.
    이는 시각적 취소선일 뿐이며 코드 동작 방식에는 영향을 미치지 않는다.

  3. 이름을 legacy_createStore 로 변경 => 가장 간단한 옵션
    @deprecation 태그가 없는 동일한 기능이다.

    	{legacy_createStore as createStore} from "redux"
    
    	const store = createStore(rootReducer);






취소선 이유 - https://github.com/reduxjs/redux/releases

redux toolkit 사용 권장 - https://redux.js.org/introduction/why-rtk-is-redux-today

profile
터벅터벅 나의 개발 일상

0개의 댓글