tramvaijs/tramvai

useRouter & Storybook

andryxxa93 opened this issue · 3 comments

Hello!
There is a component that uses the useRouter hook - it gets the back method from it. I'm trying to write stories for a component, but it gives me this error. I couldn’t find in the documentation what needs to be passed to the storybook settings to solve it.

image

In order not to create another issue, I’ll mention here that the back method from the useRouter and usePageService hooks does not return back.

Hello!

At first, stop to destructurize Router object, as I mention in previous issue)

And Router in storybook addon is just a simple mock:

useRouter can return nothing if you have a few @tinkoff/router copies, and Router Context object will be different in decorator and component.
You need to follow this guide - https://tramvai.dev/docs/guides/storybook

Thanks, it's helped!