I don't understand how argTypes/actions works. How to pass onClick function? #12768
Replies: 1 comment 1 reply
-
@piscespieces sorry for the issue you're running into. Documentation wise as you may or may not it's an ever mutating organism and constantly being updated and improved. During the transition to 6.0 it was decided to keep the documentation lean and efficient flow and snippet wise. If we decided to incorporate every use case it would eventually reach a point that it would be unmaintainable. Regarding this:
The short answer is that you don't need to. The long answer is, when you add Storybook to your project it will include the actions essentials addon along with other ones that are part of the essentials package.
By default your export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
} Breaking down the snippet above, here's what is happening. We're declaring a parameter that targets the actions (by actions the addon that is included), and telling it and Storybook to be on the lookout for any action/event that starts with Hope that it helped clarify a bit. Stay safe |
Beta Was this translation helpful? Give feedback.
-
I'm currently trying to implement an
onClick
action to a very simple component. However I'm not able to make it happen. The documentation is not clear enough by just providing little code snippets that make sense but that does not show you the overall picture.Let's say that this is my component:
ButtonTest.js
ButtonTest.stories.js
The button gets displayed in my port 9009 but as you can see, I'm not passing the
onClick
function as a prop. How am I going to be able to mock thatonClick
function that the component takes?Beta Was this translation helpful? Give feedback.
All reactions