Skip to content

Commit

Permalink
feat(*): implement Redux store
Browse files Browse the repository at this point in the history
set initialState and rootReducer
  • Loading branch information
aneurysmjs committed Dec 29, 2017
1 parent 1e8128d commit 59a72ab
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 18 deletions.
42 changes: 24 additions & 18 deletions src/Main.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import React from 'react';
import ReactDom from 'react-dom';
import { Provider } from 'react-redux';
import {
BrowserRouter as Router,
Route,
Link
} from 'react-router-dom';

// store
import store from './store';

// import main CSS styles
import './assets/scss/styles.scss';
import movies from './assets/json/movies.json';
Expand All @@ -20,24 +24,26 @@ class MainComponent extends React.Component {
render() {
return (
<Router>
<main>
<div>
<Route exact path="/" component={RmLanding} />
<Route
path="/movies"
component={props => <RmMovies movies={movies} {...props} />}
/>
<Route
path="/details/:id"
component={props => {
const { match: { params } } = props;
const movie = movies.filter(({ id }) => +params.id === id)[0];
return <RmMovieDetails movie={movie} {...props} />;
}}
/>
</div>
<RmFooter />
</main>
<Provider store={store}>
<main>
<div>
<Route exact path="/" component={RmLanding} />
<Route
path="/movies"
component={props => <RmMovies movies={movies} {...props} />}
/>
<Route
path="/details/:id"
component={props => {
const { match: { params } } = props;
const movie = movies.filter(({ id }) => +params.id === id)[0];
return <RmMovieDetails movie={movie} {...props} />;
}}
/>
</div>
<RmFooter />
</main>
</Provider>
</Router>
);
}
Expand Down
12 changes: 12 additions & 0 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const initialState = {

};

const rootReducer = (state = initialState, action) => {
switch (action.type) {
default:
return state;
}
};

export default rootReducer;
5 changes: 5 additions & 0 deletions src/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createStore } from 'redux';

import reducer from './reducers';

export default createStore(reducer);

0 comments on commit 59a72ab

Please sign in to comment.