Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. const items = (state = getDefaultItems(), action) => {
  2. switch (action.type) {
  3. case 'ADD_ITEM':
  4. return [
  5. ...state,
  6. action.data
  7. ]
  8. default:
  9. return state
  10. }
  11. }
  12.  
  13. function getDefaultItems() {
  14. const params = new URLSearchParams(window.location.hash.split("?")[1]);
  15. const items = Array.from(params.entries()).filter(item => item[0] === 'item').map(item => item[1]);
  16. return items;
  17. }
  18.  
  19. export default items
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement