phodal/growth

View on GitHub
src/redux/regex/reducer.js

Summary

Maintainability
A
1 hr
Test Coverage
import { CHOICE_REGEX } from './actions';

const initialState = {
  regex: {
    name: '',
    regex: /1-9a-Z/,
    descriptions: '',
    tag: '',
  },
};

export default function reducer(state = initialState, action = {}) {
  switch (action.type) {
    // focus action is dispatched when a new screen comes into focus
    case CHOICE_REGEX:
      return {
        ...state,
        regex: action.regex,
      };

    default:
      return state;
  }
}