Created
July 24, 2016 09:34
-
-
Save sakal/acc4b1755e582e9f729c44f7e09ae431 to your computer and use it in GitHub Desktop.
redux
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
Vladimir Grishin, [24.07.16 11:26] aka @Vogre at t.me/react_js | |
но вообще в целом | |
//actioncreator | |
const fetchData(pageNum) = dispatch=> | |
fetch('mydata', {pageNum}).then(data=>dispatch({type: 'DATA_RECEIVED', payload: {data, pageNum}})) | |
//reducer | |
switch(action.type){ | |
case 'DATA_RECEIVED': | |
return {...state, lastPageNum: action.payload.pageNum, data: state.data.concat(action.payload.data)} | |
} | |
// view | |
onClick= fetchData(store.lastPageNum+1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment