JS Built-ins
redux-legacyaction-creatorbeginner

Simple Action Creator

πŸ“– Usage Example
function increment() {
  return { type: 'INCREMENT' }
}

// Usage:
store.dispatch(increment())

Action creators centralise action construction, reducing typo-prone string duplication across the codebase.

Simple Action Creator

An action creator is a function that returns an action object. This keeps action construction consistent and centralised:

function increment() {
  return { type: 'INCREMENT' }
}

Calling increment() always produces the same action shape, making it easy to test and refactor.

Challenge: Implement increment() that returns the action object { type: 'INCREMENT' }.

πŸ’‘ Hints (2)
  • β€’ An action creator simply wraps the action object creation in a named function.
  • β€’ The return value must be a plain JavaScript object with at least a `type` string.