-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b12989
commit dcb8a3f
Showing
10 changed files
with
72 additions
and
2,234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "react-starter", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"axios": "^0.17.1", | ||
"react": "^16.2.0", | ||
"react-dom": "^16.2.0", | ||
"react-redux": "^5.0.6", | ||
"react-scripts": "1.0.17", | ||
"redux": "^3.7.2", | ||
"redux-logger": "^3.0.6", | ||
"redux-thunk": "^2.2.0", | ||
"styled-components": "^2.3.3" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import axios from 'axios' | ||
import { POSTS_URL } from '../constants/ApiConstants' | ||
import * as types from '../constants/ActionTypes' | ||
|
||
export const loadPosts = () => dispatch => { | ||
axios.get(POSTS_URL).then( | ||
res => { | ||
dispatch({ | ||
type: types.LOAD_POSTS, | ||
posts: res.data | ||
}) | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const STH = 'STH' | ||
export const LOAD_POSTS = 'LOAD_POSTS' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const POSTS_URL = `https://jsonplaceholder.typicode.com/posts` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import React from 'react' | ||
import Posts from '../components/Posts' | ||
import { connect } from 'react-redux' | ||
import { loadPosts } from '../actions' | ||
|
||
const PostsContainer = props => <Posts {...props} /> | ||
|
||
const mapStateToProps = state => ({ }) | ||
const mapStateToProps = state => ({ | ||
posts: state.post.all | ||
}) | ||
|
||
export default connect(mapStateToProps)(PostsContainer) | ||
export default connect(mapStateToProps, { | ||
loadPosts | ||
})(PostsContainer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import { createStore, applyMiddleware } from 'redux' | ||
import rootReducer from '../reducers' | ||
import logger from 'redux-logger' | ||
import thunk from 'redux-thunk' | ||
|
||
export default createStore(rootReducer, applyMiddleware(logger)) | ||
let middlewares = [logger, thunk] | ||
|
||
export default createStore(rootReducer, applyMiddleware(...middlewares)) |