Open Zelig880 opened 4 years ago
Same problem when using react
import StoryRouter from 'storybook-vue-router';
export default {
title: 'PopupMenu',
decorators: [StoryRouter],
};
export const defaultPopupMenu = () => ({
template: '<router-link to="/" />',
});
You're placing the decorators property in the wrong export I think.
You should to pass the story as an argument to the return function of the StoryRouter:
import StoryRouter from 'storybook-vue-router';
export default {
title: 'PopupMenu',
decorators: [storyFn => StoryRouter()(storyFn)]
};
export const defaultPopupMenu = () => ({
template: '<router-link to="/" />',
});
decorators: [StoryRouter()]
did it for me.
decorators: [StoryRouter()]
did it for me.
Full example with Knobs:
import StoryRouter from "storybook-vue-router";
import { withKnobs, array, object } from "@storybook/addon-knobs";
export default {
title: "Project List",
decorators: [withKnobs, StoryRouter()],
};
for those using preview.js
this works
import {addDecorator} from '@storybook/react';
import StoryRouter from 'storybook-react-router';
addDecorator(StoryRouter());
The preview.js addDecorator handling should be added to the Readme file. I had to hunt for this solution.
Building on @mszkb's example, I had to add Storybook Addon Actions to get it working. Also, I am not sure that you need to explicitly add the withKnobs
decorator (although, I already had withKnobs
defined in `.storybook/main.js). Below is what worked for me.
.storybook/main.js
like so:module.exports = {
addons: ['@storybook/addon-actions'],
};
StoryRouter
decorator.import StoryRouter from "storybook-vue-router";
export default {
title: "SomeStory",
decorators: [StoryRouter()],
};
Thank you @john-craft ..working perfectly
Issue:
Which version are you using?
1.0.7
Are you using storybook-router with a react based project or a vue one?
Vue
Please describe the problem:
I have tried to set up the above plugin with the new CSF syntax, and after debugging, i noticed that the plugin is initialised, but not triggered.
Translating to a storyOf syntax works fine.
Running the below story will trigger an error because the router is not defined.
I have tried the following different way of calling the decorator:
decorators: [StoryRouter], decorators: [StoryRouter()],
Please explain how to reproduce the issue or (better) provide an example to do it.