-
Notifications
You must be signed in to change notification settings - Fork 12
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
Gracefully handle 404 #51
Comments
Hello @dev-yakuza , this has nothing to do with the addon. You navigate to a page that does not exists, so you get an error from |
I expect it as follows. https://github.com/JesusTheHun/storybook-addon-react-router-v6#dedicated-panel I mean when I click the link, Before, I think this addon supports it. 🤔 |
This is my old repository. And I can get the Screen.Recording.2023-09-03.at.22.03.36.mov |
There was a lot of magic happening in For this reason I am very hesitant to add features that do thing on behalf of the user. My first thoughts are : Implement a parameter |
@JesusTheHun Would be nice to have an usage of |
Here is what I came up with import { Link } from 'react-router-dom';
import {
reactRouterParameters,
type ReactRouterAddonStoryParameters,
} from 'storybook-addon-react-router-v6';
export const withDefaultRouting = (params: {
routing: { path: string };
location: ReactRouterAddonStoryParameters['location'];
}) => {
return reactRouterParameters({
location: {
...params.location,
path: params.routing.path,
},
routing: [
{
path: params.routing.path,
useStoryElement: true,
},
{
path: '*',
element: <Link to={params.routing.path}>404, Go back</Link>,
},
],
});
}; and then I just use that in my Story parameters like so ...
parameters: {
reactRouter: withDefaultRouting({ routing: { path: '/some-path/:withParam' }, location: {
pathParams: 'paramValue' } })
} |
I think what this really needs is just some examples of a story setup with navigation elements. I was running into this same issue when writing stories for a nav menu, just a simple sidebar with NavLinks that's shown on every page. Any time I clicked a link it would crash. It took me some testing to figure out what configuration I actually needed, and the documentation was not very helpful in this regard. In the end I settled on this:
I think a few example scenarios and their stories would be a big help for anyone using this plugin. Off the top of my head some useful candidates would be:
I'm happy to put together a pull request with these examples if I can figure out how to set them up. |
@EPurwanto those examples are helpful indeed. It would be nice to also have a test to validate it works as expected. Is this something you can do ?
What do you need to figure out exactly ? I would be happy to help you with it. |
Last time I used React Router was v4, and Storybook was v6, so all of it lol. I'll basically be building all of those examples for work, so once I've done that I should be able to throw together some simple example stories. Probably in a week or so. Can't promise unit tests with it, as I haven't done a lot of tests for frontend, but I'll see how I go. |
First, thanks for making the great addon. 🙇
Error
Recently, I got the following error when I pressed the link component(
react-router-dom
).Expect
I hope the click action will be shown in the
React Router
tap without any error.Repository
I make a repository about this error. So you can see the error when you run the repository.
I executed the following commands to make the repository.
And modified the files.
.storybook/preview.ts
I would really appreciate it if you could solve the problem or tell me how to solve it. 🙇
The text was updated successfully, but these errors were encountered: