Stan aplikacji

state/redux-toolkit

New and maintained Redux code uses Redux Toolkit's configureStore and createSlice, not the legacy createStore.

drobnastatycznefe-state

Dlaczego

The Redux maintainers consider the bare redux core obsolete for app code. A store built with createStore misses the development checks that configureStore adds (accidental mutation, values that cannot be serialised), and hand-written action types, action creators and immutable updates are where most Redux bugs live.

Poprawka

Replace createStore(rootReducer) with configureStore({ reducer: { … } }) from @reduxjs/toolkit, then move reducers to createSlice one at a time. Server data belongs in RTK Query or TanStack Query rather than in hand-written thunks and slices.

Przykłady

// bad
import { createStore, combineReducers } from 'redux'
export const store = createStore(combineReducers({ todos }))
// good
import { configureStore } from '@reduxjs/toolkit'
export const store = configureStore({ reducer: { todos } })

Źródła

Fakty

Identyfikator
state/redux-toolkit
Waga
drobna
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
jsx
Tylko w projektach z
redux
Uczy jej skill
fe-state State and stores
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain state/redux-toolkit