javascript - redux/react-redux Provider TypeError: Object(...) is not a function
问题描述
为什么TypeError: Object(...) is not a function
在尝试使用store
道具时出现此错误<Provider store={store}/>
//Error in browser from Create-React-App
TypeError: Object(...) is not a function
8 | var store = _ref.store,
9 | context = _ref.context,
10 | children = _ref.children;
> 11 | var contextValue = useMemo(function () {
| ^ 12 | var subscription = new Subscription(store);
13 | subscription.onStateChange = subscription.notifyNestedSubs;
14 | return {
//index.js (in root of project)
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducers from './reducers/index.js'
const store = createStore(reducers);
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
);
// 我的reducers
文件夹在同一级别。有两个文件:index.js
和photos.js
索引.JS
import { combineReducers } from 'redux'
import { Photos } from './photos'
const reducers = combineReducers({
Photos
})
export default reducers
照片.JS
import { SET_PHOTOS } from '../actions/photos'
const DATA = {
photos: []
}
export const Photos = (state = DATA, action) => {
switch(action.type) {
case SET_PHOTOS:
return {
...state,
photos: action.payload,
};
default:
return state
}
}
这是一个 create-react-app 设置。我并没有真正使用它,而我已经多次完成的这个简单任务让我很难过。
解决方案
推荐阅读
- java - BufferedImage getSubimage 以看似不错的论点抛出异常
- .net - netstandard2.0 (.net standard 2.0) 类库不能引用 net461 (.net framework 4.6.1) 类库
- sql-server - SQL Server 中的 Nvarchar
- go - 处理两个连续错误
- java - 从文件中读取 - 堆满
- jdbc - 如何在 Telosys CLI 中设置 JDBC 驱动程序 JAR 以创建 dbmodel
- spring - 在 RuntimeEnvironment 中包含 BPMN 文件的问题
- oracle - Oracle Scheduler proc 未在下一次开始时间之前完成
- java - 将 Perl 正则表达式转换为 Java
- scala - 在 Scala Play (2.6) EssentialFilter 中处理对 Future 完成的依赖