Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saga argument must be a Generator function! error #69

Open
seanmalek opened this issue May 1, 2020 · 4 comments
Open

saga argument must be a Generator function! error #69

seanmalek opened this issue May 1, 2020 · 4 comments

Comments

@seanmalek
Copy link

I have code that was working fine until I upgrade the okta-react to 3.0.1 and now I am getting this weird error runSaga(options, saga, ...args): saga argument must be a Generator function!

  10 | export const store = createStore(rootReducer, getInitialState(), composeWithDevTools(applyMiddleware(sagaMiddleware)));
  11 | 
> 12 | sagaMiddleware.run(rootSaga);
     |                ^
  and my root saga is 

export const rootSaga = function* root() {
yield all([
fork(watchNewGeneratedNetworkRequestStart),
fork(watchGetRefsStartSaga),
fork(watchCommercialOrderSearch),
fork(watchSessionNetworkSaga),
fork(watchMissingCopySearch),
fork(watchMissingCopyRefSaga),
fork(watchAddInstruction),
fork(watchMediaSearches),
fork(watchLockSagas),
fork(watchSharedCommercialOrderSearch),
fork(watchMultiOrderInstructionSagas),
fork(watchLogPageSagas),
]);
};

any idea why I started having this errors after the update?

@grinya007
Copy link

Hi, Sean
If you remove default from export default function* rootSaga() line in your sagas.js this error should go away.
Don't ask why, I'm in the very beginning of the journey to javascript wonderland =)

@grinya007
Copy link

Oh, just realized that this is your rootSaga below the code snippet (looks like some stack trace =)
I'd suggest replacing export const rootSaga = function* root() { with export function* rootSaga() {

@hamaarouf
Copy link

I got the same error while I was following this tutorial from redux-saga doc https://redux-saga.js.org/docs/introduction/BeginnerTutorial#making-asynchronous-calls

Any solution/explanation please ?

@outa-time
Copy link

Make sure your generator function is written with the space before the asterisk:

export function *helloSaga() {

and NOT with the space after the asterisk:

export function* helloSaga() {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants