zatziky zatziky - 3 months ago 17
Javascript Question

How to get action.params from saga

I am

redux-saga
. In the code
yield* ReduxSaga.takeEvery('MY_ACTION', updatePorts);
how can I access the
action
to get its fields.

For example I have an action creator:

function status(){
type: 'MY_ACTION',
status: true
}


How can I access
action.status
from my saga? Or do I have to access data only via
getState()
and select?

Answer
const actionCreator=()=>({
  type: 'MY_ACTION',
  status:true
})

 function* updatePorts(action) {
  console.log(action.status)
}

function* watchUpdatePorts() {
  yield* takeEvery('MY_ACTION', updatePorts)
}

https://yelouafi.github.io/redux-saga/docs/api/index.html#takeeverypattern-saga-args

Comments