gpt4 book ai didi

javascript - 预期 reducer 是一个函数 - React Native、Redux

转载 作者:行者123 更新时间:2023-11-29 00:24:35 25 4
gpt4 key购买 nike

我正在学习 React Native 和 Redux,但我的代码中遇到了一个我无法解决的问题。当我在 iPhone 模拟器 (iOS 10.3) 上运行我的代码时,出现错误:“Expected the reducer to be a function”。

这是我的所有代码(很短,很基础):

src/app.js:

import React from 'react';
import { View } from 'react-native';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducers from './reducers';
import {Header} from 'native-base';

const App = () => {
return(
<Provider store={createStore(reducers)}>
<View>
<Header />
</View>
</Provider>
)
}

export default App;

src/reducers/index.js:

import { combineReducers } from 'redux';

export default combineReducers({
libraries: () => []
});

index.ios.js:

import {AppRegistry} from 'react-native';
import App from './src/app';

AppRegistry.registerComponent('project', () => App);

the exact error message

谢谢大家 荣荣。

最佳答案

我犯的一个错误是使用 import {reducers } from '../reducers/myReducer'; 而不是 import reducers from '../reducers/myReducer';, which yielded the same error message.

关于javascript - 预期 reducer 是一个函数 - React Native、Redux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43410209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com