对于我的react-native项目,我在长时间的RnD之后遇到了这个错误,我仍然无处可去,我不知道是什么导致了这个问题,
我阅读了react-native,redux,react-redux和我使用的所有其他库的所有开放和关闭的问题。我甚至尝试创建一个没有代码的新项目,但redux安装和问题仍然存在。
以下是我的package.json依赖项的代码:
"dependencies": {
"@react-native-async-storage/async-storage": "^1.21.0",
"react": "18.2.0",
"react-native": "0.73.0",
"react-redux": "^9.0.2",
"redux": "^5.0.0",
"redux-logger": "^3.0.6",
"redux-persist": "^6.0.0",
"redux-thunk": "^3.1.0"
},
字符串
-> App.js:
import {store, persister} from './src/redux/store';
import {Provider} from 'react-redux';
import {PersistGate} from 'redux-persist/lib/integration/react';
import {View, Text} from 'react-native';
const App = () => {
return (
<Provider store={store}>
<PersistGate persistor={persister}>
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}}>
<Text
style={{
color: 'black',
}}>
App
</Text>
</View>
</PersistGate>
</Provider>
);
};
export default App;
型
-> store.js:
import {createStore, applyMiddleware} from 'redux';
import AsyncStorage from '@react-native-async-storage/async-storage';
import {persistStore, persistReducer} from 'redux-persist';
import reducers from './reducers';
import middleware from './middlewares';
const persistConfig = {
key: 'root',
storage: AsyncStorage,
blacklist: [],
};
const pReducer = persistReducer(persistConfig, reducers);
const store = createStore(pReducer, applyMiddleware(...middleware));
const persister = persistStore(store);
export {store, persister};
型
-> middlewares.js:
import {createLogger} from 'redux-logger';
import thunk from 'redux-thunk';
const middleware = [];
const logger = createLogger();
middleware.push(logger, thunk);
// commiting logger for release
// middleware.push( thunk);
export default middleware;
型
2条答案
按热度按时间nzkunb0c1#
你可以尝试修改这一行,这可能是由于没有默认的出口存在!
-> store.js:
字符串
krugob8w2#
我也面临着同样的问题,没有什么工作,然后我回到所有redux相关库的旧版本,一切都开始完美地工作,这里是我的依赖项
字符串
希望它也能为你工作。