Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. var Immutable = require('immutable');
  2. var deepFreeze = require('deep-freeze');
  3.  
  4. import * as types from '../actions/actionTypes';
  5.  
  6. const initialState = {
  7. customBackgroundColour: '#f7f7f7'
  8. };
  9.  
  10. export default function backgroundColour(state = initialState, action = {}) {
  11.  
  12. switch (action.type) {
  13. case types.SET_BACKGROUND_COLOUR:
  14.  
  15. deepFreeze(state);
  16. deepFreeze(action);
  17.  
  18. console.log(Object.isFrozen(state)); // true
  19. console.log(state.customBackgroundColour); // #f7f7f7
  20.  
  21. state.customBackgroundColour = 'red';
  22. console.log(state.customBackgroundColour); // red
  23.  
  24. return {
  25. ...state,
  26. customBackgroundColour: action.payload.colour
  27. };
  28. default:
  29. return state;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement