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

Integration in Saga #41

Closed
dbrrt opened this issue Apr 8, 2020 · 8 comments
Closed

Integration in Saga #41

dbrrt opened this issue Apr 8, 2020 · 8 comments

Comments

@dbrrt
Copy link

dbrrt commented Apr 8, 2020

Hello,

Is it possible to use this library in Redux Saga, if so how?

Thanks in advance.

@danielr18
Copy link
Owner

@dbrrt Hello, it's possible to use it.

It depends on what you want to do, you can dispatch Router methods from your sagas, or read the location state from the store.

Let me know if I can help you further

@dbrrt
Copy link
Author

dbrrt commented Apr 8, 2020

@danielr18 Thanks for the quick reply, I've tried to wrap my main App with <Provider> and <ConnectedRouter>, but it had no effect when calling actions from the library. I'm using hooks in my functional components can it be an anti-pattern with your library?

@danielr18
Copy link
Owner

Are you using the redux middleware?

Here's v2 example: https://github.com/danielr18/connected-next-router/tree/v2/examples/basic

@dbrrt
Copy link
Author

dbrrt commented Apr 8, 2020

Yes, but probably misconfigured. Will try again. Thanks for the link!

EDIT: Quickly adapted from the example your shared.
It works just fine with Saga.

Here's how I'm updating the route in my sagas in my generators.
yield put(push({ pathname: '/new-path'}))

Unfortunately I'm still having Server side rendering issues: Error: No router instance found. You should only use "next/router" inside the client side of your app.

@danielr18
Copy link
Owner

Are you dispatching a navigation action on the server side?

@dbrrt
Copy link
Author

dbrrt commented Apr 8, 2020

That was the issue, performing the dispatch on the client side only resolved the problem

@dbrrt
Copy link
Author

dbrrt commented Apr 8, 2020

Thanks a lot @danielr18, this issue can be closed, I can try to make a PR with an example for Saga once I've got a moment.

@danielr18
Copy link
Owner

@dbrrt That would be great, thanks!

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

2 participants