Filth
Filth

Reputation: 3228

Redux Setup | ReactJS | ES6

I'm new to Redux so trying to get this going within my app - I'm getting the following error:

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

There's not a whole heap of documentation on how to get Redux setup out there. I know of this site: http://redux.js.org/ however this wasn't much help.

Not sure what I'm missing?

Here are my files:

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;

Upvotes: 0

Views: 233

Answers (1)

Bryan Fillmer
Bryan Fillmer

Reputation: 548

Within Reducers/index.js, change it to export default store;, you are exporting the reducers object, which you then attempt to run as a function in Client.js.

Upvotes: 1

Related Questions