Search code examples
reactjsreduxredux-sagasaga

How can i call this action from my saga generator function?


Im in React v16, Redux, saga 1.1.3, AWS cognito for UserMgmt

Requirements:

after creating a new user, email them a password reset link so they can log in and set their password

password reset action works perfectly new user creation works perfectly

I need to call the pwd reset action once the new user is created. I'm targeting the saga as a good place to make this call. Once all the yields for the existing saga are done, right before setting state with put, i make one more yield call to the other action i want to run...and never see it do anything : )

is there a trick to running or dispatching actions from sagas.

this is the one line i need to run

cognitoActions.forgotPwd(email);

running it from my front end works every time.

also, it is imported

import { cognitoActions } from "fakepath/cognito";

on the front end mapping the action to props, passing it to the component, then calling it works every time...

just no action from the saga. i've tried logging results and dont think its running at all, no console.log happens...


Solution

  • You can use the "put" function to call it from within an effect like this:

    yield put(action)
    

    Potentially depending on what you want you can use:

    putResolve(action)
    

    You can find documentation for this here:

    https://redux-saga.js.org/docs/api/