Skip to content

Instantly share code, notes, and snippets.

@sakal
Created July 24, 2016 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakal/acc4b1755e582e9f729c44f7e09ae431 to your computer and use it in GitHub Desktop.
Save sakal/acc4b1755e582e9f729c44f7e09ae431 to your computer and use it in GitHub Desktop.
redux
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