Stories for errorElements #69
-
Hello, I'm trying to figure out how to write stories for components used in the The initial thought is to treat the component as any component and just write a regular story for it. But my error element uses Hence, I could have a bogus component as story component, and the error component as
Now the So, how can I reliably render an |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
So if I understand your issue correctly, your problem is that the decorators of your story are not rendered, because the real story is actually the error component, right ? The first thing that comes to mind is to split the component : one that calls Also, the order of the decorators matters. It defines who wraps who. So if the router decorator comes first, even your error component will be wrapped, as you can see in this stackblitz : https://stackblitz.com/edit/storybook-addon-remix-react-router-d6htzf?file=src%2Fstories%2Fbasics.stories.tsx |
Beta Was this translation helpful? Give feedback.
So if I understand your issue correctly, your problem is that the decorators of your story are not rendered, because the real story is actually the error component, right ?
The first thing that comes to mind is to split the component : one that calls
useRouteError()
and one that accept the result of that call as a prop. This way you can make your story using the stateless component.Also, the order of the decorators matters. It defines who wraps who. So if the router decorator comes first, even your error component will be wrapped, as you can see in this stackblitz : https://stackblitz.com/edit/storybook-addon-remix-react-router-d6htzf?file=src%2Fstories%2Fbasics.stories.tsx