1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-11 18:32:50 +00:00

added redux

This commit is contained in:
2016-08-18 16:10:19 +00:00
parent c572b3806d
commit 2cfda4bb4f
13 changed files with 172 additions and 65 deletions

View File

@@ -0,0 +1,23 @@
import * as types from "./constants";
function initPreview(posts){
return{
type: types.INIT_PREVIEW,
posts
}
}
//using redux-thunk we can modify actions before they get called
//in this case we can send the http request here rather in the react component
export function fetchPreview(){
return (dispatch) => {
return fetch('/metadata.json')
.then(response => response.json())
.then(json => {
dispatch(initPreview(json));
})
.catch(error => {
console.log(error);
});
}
}