Redux · Schema

Redux Action

Schema for a Redux action object. Actions are plain JavaScript objects that represent an intention to change the state. Every action must have a type field.

Flux ArchitectureFrontendJavascriptPredictable StateReactState ManagementTypescript

Properties

Name Type Description
type string A string constant identifying the kind of action being performed. By convention written in SCREAMING_SNAKE_CASE.
payload object Any data that accompanies the action. Follows the Flux Standard Action convention.
error boolean When true, the payload is treated as an error object. Follows the Flux Standard Action convention.
meta object Extra information that is not part of the payload. Follows the Flux Standard Action convention.
View JSON Schema on GitHub

JSON Schema

redux-action-schema.json Raw ↑
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://api-evangelist.github.io/redux/json-schema/redux-action-schema.json",
  "title": "Redux Action",
  "description": "Schema for a Redux action object. Actions are plain JavaScript objects that represent an intention to change the state. Every action must have a type field.",
  "type": "object",
  "required": ["type"],
  "properties": {
    "type": {
      "description": "A string constant identifying the kind of action being performed. By convention written in SCREAMING_SNAKE_CASE.",
      "type": "string",
      "examples": [
        "INCREMENT",
        "USER_FETCH_SUCCEEDED",
        "todos/addTodo",
        "counter/increment"
      ]
    },
    "payload": {
      "description": "Any data that accompanies the action. Follows the Flux Standard Action convention.",
      "oneOf": [
        {"type": "string"},
        {"type": "number"},
        {"type": "boolean"},
        {"type": "object"},
        {"type": "array"},
        {"type": "null"}
      ]
    },
    "error": {
      "description": "When true, the payload is treated as an error object. Follows the Flux Standard Action convention.",
      "type": "boolean",
      "default": false
    },
    "meta": {
      "description": "Extra information that is not part of the payload. Follows the Flux Standard Action convention.",
      "type": "object",
      "additionalProperties": true
    }
  },
  "additionalProperties": false,
  "examples": [
    {
      "type": "INCREMENT"
    },
    {
      "type": "todos/addTodo",
      "payload": {
        "id": 1,
        "text": "Buy milk",
        "completed": false
      }
    },
    {
      "type": "USER_FETCH_FAILED",
      "payload": {
        "message": "Network request failed"
      },
      "error": true
    }
  ]
}