Last active
April 28, 2022 13:45
-
-
Save kitze/100efcc21597533e8ca8737aa8947dbf to your computer and use it in GitHub Desktop.
mobx store wrapper for storybook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How would you use this though?