Redux 设置 |反应JS | ES6
Redux Setup | ReactJS | ES6
我是 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>
);
}
}
Reducers/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;
在 Reducers/index.js
中,将其更改为 export default store;
,您正在导出 reducers
对象,然后您尝试将其 运行 作为 [=13= 中的函数].
我是 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>
);
}
}
Reducers/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;
在 Reducers/index.js
中,将其更改为 export default store;
,您正在导出 reducers
对象,然后您尝试将其 运行 作为 [=13= 中的函数].