How to pass arguments to redux-saga

Viewed 7266

I am familiar with redux-thunk, and today I come to redux-saga, I know that when we want to handle asynchronous, with redux-saga, we need to call an actions as signal first and then sagas will handle and return success/fail actions, so, if I want to pass argument from react component ( pass search-value to search) but my first actions is just the signal, so, how to pass value to the action in charge, thank you

1 Answers

first actions is just the signal, so, how to pass value to the action in charge, thank you

In general case, redux action is custom-form object with mandatory field type, so it can carry enough information. Common use-case with redux-saga is emitting from React component action like MY_ACTION_REQUEST, which is intercepts with some saga process, performs asynchronous reaction and emit action like MY_ACTION_SUCCESS or MY_ACTION_FAIL, depending on successful state of operation.

If you are using some action creators, like bindActionCreators, just pass subsequent arguments into target action-creator function. You can see details in that answer: https://stackoverflow.com/a/44066279/7878274

Related