Storybook Actions - what exactly are they calling?
Ok, as Jack would've said let's go by parts. First of all:
I would like an explanation of how storybook actions work
storybook-actions
is an addon to Storybook's platform. Actions provide you with a mechanism that logs user interactions and data as it flows through your components in the Storybook's UI. action()
is actually a high-order function
wich returns another function similar to console.log()
, the only difference here is that besides logging the user's activity and perform other operations, the name of the action (end, swipe-left, ...) will also be rendered on your storybook's action panel.
The event handler functions that
action()
creates are useful for as a substitute for actual event handler functions that you would pass to your components. Other times, you actually need the event handling behavior to run. For example, you have a controlled form field that maintains its own state and you want to see what happens as the state changes
See this article about actions
for more information
Second:
A perfect answer would explain how to make the cards repeat after a user finished going through a stack
This actually doesn't have anything to do with actions or even with storybook, this logic is implemented by react-swipe-card
package, and here I admit my incompetence, I even tried to go through the source, but is just so messy that is almost impossible to understand exactly what's going on, the logic that you are looking for is just a carousel
, that checks if the next element is null
or undefined
and case true just start all over. Or if the previous element is null
or undefined
and case true go to the last element. I advise you to find other library most reliable like react-swipeable-views