“Redux Toolkit Store” Ответ

Redux Toolkit с Redux сохраняется

import {configureStore} from '@reduxjs/toolkit';
import storage from 'redux-persist/lib/storage'
import {combineReducers} from "redux"; 
import { persistReducer } from 'redux-persist'
import thunk from 'redux-thunk'

const reducers = combineReducers({
 //...            
});

const persistConfig = {
    key: 'root',
    storage
};

const persistedReducer = persistReducer(persistConfig, reducers);


const store = configureStore({
    reducer: persistedReducer,
    devTools: process.env.NODE_ENV !== 'production',
    middleware: [thunk]
});

export default store;
Determined Dugong

Redux Toolkit Store

// store.js

import { configureStore } from '@reduxjs/toolkit'

export const store = configureStore({
  reducer: {},
})


// index.js 

import { store } from './app/store'
import { Provider } from 'react-redux'

ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('root')
)

Yafet Segid

Redux Toolkit с Redux сохраняется

import store from './app/store';
import { PersistGate } from 'redux-persist/integration/react'
import { persistStore } from 'redux-persist'

let persistor = persistStore(store);

    <Provider store={store}>
        <PersistGate loading={null} persistor={persistor}>
        <App/>
        </PersistGate>
    </Provider>,
Determined Dugong

Redux Toolkit и структура папок

1npx create-react-app my-app --template redux
Jeepers Greepers

Ответы похожие на “Redux Toolkit Store”

Вопросы похожие на “Redux Toolkit Store”

Больше похожих ответов на “Redux Toolkit Store” по JavaScript

Смотреть популярные ответы по языку

Смотреть другие языки программирования