tonyhb / redux-ui

Easy UI state management for react redux
637 stars 64 forks source link

fix problem with react-redux#6 fi #90

Closed cristian-sima closed 5 years ago

cristian-sima commented 5 years ago

fix #89

cristian-sima commented 5 years ago

@tonyhb

cristian-sima commented 5 years ago

It seems it is difficult to modify it. I replace redux-ui with this simple reducer:

// @flow

const reducer = (state : any, action : any) => {
  const { payload } = action;

  switch (action.type) {
    case "UPDATE_BOARD":
      return state.set(payload.key, payload.value);

    case "CLEAR_BOARD":
      return state.delete(payload.key);
    default:
      return state;
  }
};

const getFromBoard = (state : any, key : string) => (
  state.getIn([
    "board",
    key,
  ])
);

export const selectors = {
  getFromBoard,
};

export default reducer;