You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the docsbeforeEach is called before each story mount. Empirically I note that:
a) it is also called before every re-render of the story - ie: when args update
b) a returned cleanup function is only called after the story is unmounted - not before subsequent beforeEach calls on re-renders
This means each beforeEach needs to handle an environment where it has already been run on the current story.
Are both a) and b) are as designed?
Is there or should the be a way for beforeEach code to know whether it has already run on the current story
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Summary
According to the docs
beforeEach
is called before each story mount. Empirically I note that:a) it is also called before every re-render of the story - ie: when args update
b) a returned cleanup function is only called after the story is unmounted - not before subsequent
beforeEach
calls on re-rendersThis means each
beforeEach
needs to handle an environment where it has already been run on the current story.beforeEach
code to know whether it has already run on the current storyThanks!
Additional information
No response
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions