Search code examples
reduxnaming-conventionsnamingredux-actions

Using the word "type" in redux actions


I'm trying to use Redux with React Native recently. As far as I know, the word "type" is restricted by the Redux, that is, if there is a property in my property, it won't work together.

{ 
  type: 'MODIFY_USER',
  gender: 'male',
  type: 'normal_user', // <= this is the type of the user specified to modify,
}

Since every naming is perfectly mapped in my code. How should I adapt with this??


Solution

  • You can take the "payload" approach:

    { 
      type: 'MODIFY_USER',
      payload: {
        gender: 'male',
        type: 'normal_user', // <= this is the type of the user specified to modify,
      }
    }