redux 如何在react native中使用多个还原器

6mzjoqzu  于 2022-11-12  发布在  React
关注(0)|答案(2)|浏览(109)

我有两个还原器学生还原器和员工还原器,我想在我的代码中使用这两个还原器,但我不知道如何做到这一点请帮助我。

import React from 'react'
import { Provider as PaperProvider } from 'react-native-paper'
import AppNavigator from './src/navigation'
import { Provider as StoreProvider } from 'react-redux'
import { createStore, combineReducers } from 'redux';
import studentReducer from './src/store/reducers/studentStore'
import employeeReducer from './src/store/reducers/employeeStore'

const rootReducer = combineReducers({
stuedntReducer,
employeeReducer,
});

const store = createStore(rootReducer);

export default function App() {
return (
   <StoreProvider store={store}>
     <PaperProvider>
       <AppNavigator />
     </PaperProvider>
   </StoreProvider>
  )
}
oxosxuxt

oxosxuxt1#

我不知道你有没有Reference Error,但看看这个。
您已导入

import studentReducer from './src/store/reducers/studentStore'

并在combineReducer()中使用了

const rootReducer = combineReducers({
stuedntReducer,
employeeReducer,
});

所以stuedntReducer

56lgkhnf

56lgkhnf2#

import { createStore } from "redux";
import { Reducers } from "../reducer/Reducers";
import { Reducers1 } from "../reducer/Reducers";
import { Reducers2 } from "../reducer/Reducers";
import { Reducers3 } from "../reducer/Reducers";
import { Reducers4 } from "../reducer/Reducers";

export const Mystore = createStore(
Reducers1
Examplereducer   // use multipal reducers
Examplereducer1
Examplereducer2
Examplereducer3
)

相关问题