Redux设置| ReactJS | ES6

时间:2016-05-05 10:10:59

标签: reactjs redux react-redux

我是Redux的新手,所以试图在我的应用中实现这一点 - 我收到了以下错误:

Uncaught TypeError: (0 , _index2.default) is not a function

还没有关于如何在那里安装Redux的大量文档。我知道这个网站:http://redux.js.org/但是这并没有多大帮助。

不确定我错过了什么?

以下是我的文件:

Client.js

//Client entry

//Application modules
import React from "react";
import { Provider } from "react-redux";

import ReactDOM from "react-dom";
import { Router, Route, IndexRoute, hashHistory } from "react-router";
import { createStore } from "redux";
import reducers from "./reducers/index";



//Application views
import Layout from "./components/Layout";
import ForgotPassword from "./containers/ForgotPassword/ForgotPassword";
import Login from "./containers/Login/Login";
import Register from "./containers/Register/Register";


const store = createStore(reducers());

const app = document.getElementById('app');

ReactDOM.render(
    <Provider store={store}>
        <Router history={hashHistory}>
            <Route path="/" component={Layout} />
            <Route path="/login" component={Login} />
            <Route path="/register" component={Register} />
            <Route path="/forgotpassword" component={ForgotPassword} />
        </Router>
    </Provider>,
app); 

export default store;

Layout.js

import React, {Component} from "react";

import Footer from "./Footer/Footer";
import Header from "./Header/Header";

import Login from "../containers/Login/Login";
import Register from "../containers/Register/Register";
import ForgotPassword from "../containers/ForgotPassword/ForgotPassword";

export default class Layout extends Component {
  constructor() {
    super();
  } 

  render() {
    return (  
      <div>
        <Header />
        <Login />
        <Register />
        <ForgotPassword />
        <Footer />
      </div>
    );
  }
}

减速/ index.js

import { createStore, combineReducers } from "redux";
import { reducer as formReducer } from "redux-form";

const reducers = {
    form: formReducer 
}

const reducer = combineReducers(reducers);
const store = createStore(reducer);

export default reducers;

1 个答案:

答案 0 :(得分:1)

export default store;中,将其更改为reducers,您要导出Client.js对象,然后尝试将其作为{{1}}中的函数运行。