In my react project I have the following code.
export function* onDisplayAlert({ payload }: any) {
payload.id = getUniqueID();
yield put(setAlert(payload));
yield setTimeout(() => {
yield put(removeAlert(payload.id));
}, 3000);
}
What I want to do here is use yield inside setTimeOut callback.
yield put(removeAlert(payload.id));
But the way I have written this doesn't work.Because arrow function callback is not a generator function, so I can't use yield inside it. How can I use yield inside setTimeOut?