furdzik / IF.Kamisama

Complete Style Guide for writing frontend code by Izabela Furdzik [WIP]
MIT License
0 stars 0 forks source link

[Redux] United convention for the naming payload of actions #22

Open furdzik opened 3 years ago

furdzik commented 3 years ago

https://redux.js.org/style-guide/style-guide#write-actions-using-the-flux-standard-action-convention

furdzik commented 3 years ago

[PROPOSITION 1]

const someAction = (something) => ({
  type: actionTypes.SOME_ACTION,
  payload: {
    something
  }
})
furdzik commented 3 years ago

[PROPOSITION 2]

const someAction = (something) => ({
  type: actionTypes.SOME_ACTION,
  payload: something
})
furdzik commented 3 years ago

[PROPOSITION 3]

const someAction = (payload) => ({
  type: actionTypes.SOME_ACTION,
  payload
})
furdzik commented 3 years ago

Bad examples:

  1. No payload
    const fetchListingSuccess = (listing, canLoadMoreEvents, currentFilters, initialFilterValues) => ({
    type: actionTypes.FETCH_LISTING_SUCCESS,
    listing,
    canLoadMoreEvents,
    currentFilters,
    initialFilterValues
    });