Skip to content

Instantly share code, notes, and snippets.

@kitze
Last active April 28, 2022 13:45
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitze/100efcc21597533e8ca8737aa8947dbf to your computer and use it in GitHub Desktop.
Save kitze/100efcc21597533e8ca8737aa8947dbf to your computer and use it in GitHub Desktop.
mobx store wrapper for storybook
import React from 'react';
import {Provider} from 'mobx-react';
const stub = () => true;
export const exampleStore = {
app: {},
auth: {
checkAuth: stub
},
router: {
goTo: stub
}
};
const wrapWithStore = (extendStore = {}, overrideStore) => story => {
const cleanStore = {};
const finalStore = overrideStore ? overrideStore : {...cleanStore, ...exampleStore, ...extendStore};
return (
<Provider store={finalStore}>
{story()}
</Provider>
)
}
export default wrapWithStore;
@stigi
Copy link

stigi commented Aug 21, 2018

Thanks for the inspiring Gist. You're using JSX, so you probably want your file extension to reflect that.

@radum
Copy link

radum commented Mar 26, 2019

How would you use this though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment