RERED REDUX-未捕获的TypeError:Object(...)不是ConnectFunction上的函数

时间:2019-04-19 18:03:21

标签: reactjs redux react-redux

我正在尝试将redux设置到我的react项目中,当我使用connect函数并将其包装在组件周围时,会弹出此错误。

我尝试遍历文档,并根据我的知识执行每个步骤,但错误似乎总是会发生

This is the error screenshot

Routes.js

import {connect} from 'react-redux';

class Routes extends React.Component {

 }

const mapStateToProps = (state) => {
  return {
    posts: state
  }
}

export default connect(mapStateToProps)(Routes)

rootReducer.js

const initialState = {
  posts: [
    {id: 1, data: "Hello There"},
    {id: 2, data: "Hello There Nav"},
    {id: 3, data: "Hello There Mon"}
  ]
};

const rootReducer = (state = initialState, action) => {
  return state;
};

export default rootReducer;

index.js

import {createStore} from 'redux';
import {Provider} from 'react-redux';
import rootReducer from './reducers/rootReducer';

const store = createStore(rootReducer, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());

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

0 个答案:

没有答案