-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hook on leaveing a story #845
Comments
Comment by mnmtanish I think we should be able to do this with a decorator. The basic idea is to wrap the story with a component and run the hook function on storiesOf('Button', module)
.addDecorator(storyHook({
componentWillUnmount() {
// reset screen orientation
}
}))
.add('story - 1', () => (
<pre>STORY_1</pre>
)) |
Comment by linonetwo That would be much more easy to use. I'm currently having to use redux to do this clean up work for every component. storiesOf('LineChart', module)
.addDecorator((getStory) => {
const store = getNewStore();
const token = 'e77b3f75-1daa-4ded-b52a-7bbd65f758f5';
store.dispatch(STORYBOOK.request({ orientation: 'landscape' }));
store.dispatch(LOGIN.request({ token, jump: false }));
Orientation.lockToLandscape();
Promise.delay(2000)
.then(() => {
store.dispatch(LOAD_LINE_CHART.request({ areaType: 'Company', jump: false }));
});
return (
<Provider store={store}>
{getStory()}
</Provider>
);
})
.add('initial', () => (
<LineChart areaType="Company" />
)); Where |
#845 (comment) sounds like an acceptable solution? Please re-open if you still experience this problem 👍 |
Issue by linonetwo
Monday Jan 16, 2017 at 02:53 GMT
Originally opened as storybook-eol/react-native-storybook#120
Some component will change Orientation of device, so seems that we need a hook to revert the changing of Orientation on leaving a story.
The text was updated successfully, but these errors were encountered: