Skip to content

Commit

Permalink
#4 setup redux boilerplate and folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjoha committed Feb 25, 2019
1 parent 6831463 commit 0beaef4
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { connect } from 'react-redux'

class App extends Component {
render() {
console.log(this.props.query)
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
{this.props.query.hei}
Edit <code>src/App.js</code> and save to reload.
</p>
<a
Expand All @@ -25,4 +28,11 @@ class App extends Component {
}
}

export default App;
const mapStateToProps = (state) => (
{
query: state.query
}
)


export default connect(mapStateToProps)(App);
8 changes: 7 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import { createStore, applyMiddleware } from 'redux';
import { Provider } from 'react-redux'
import thunk from 'redux-thunk'
import rootReducer from './reducers/rootReducer'

ReactDOM.render(<App />, document.getElementById('root'));
const store = createStore(rootReducer, applyMiddleware(thunk));

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

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
Expand Down
5 changes: 5 additions & 0 deletions src/reducers/filterReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const filterReducer = ( state={}, action ) => {
return state
}

export default filterReducer;
5 changes: 5 additions & 0 deletions src/reducers/queryReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const queryReducer = (state={hei:'hei'}, action) => {
return state
}

export default queryReducer
5 changes: 5 additions & 0 deletions src/reducers/resultReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const resultReducer = (state={}, action) => {
return state
}

export default resultReducer
13 changes: 13 additions & 0 deletions src/reducers/rootReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { combineReducers } from 'redux'

import queryReducer from './queryReducer'
import filterReducer from './filterReducer'
import resultReducer from './resultReducer'

const rootReducer = combineReducers({
query: queryReducer,
filter: filterReducer,
result: resultReducer
})

export default rootReducer

0 comments on commit 0beaef4

Please sign in to comment.