Created
July 30, 2018 10:33
-
-
Save axelnormand/3d8723f8566733089eab21015a1259fd to your computer and use it in GitHub Desktop.
React Native Stroybook
This file contains 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 { configure, getStorybookUI } from '@storybook/react-native'; | |
import React from 'react'; | |
import { getConfig } from 'src/config'; | |
import { | |
allStories, | |
loadStories, | |
} from 'src/test/storybook/storyshots/allStories'; | |
/** | |
* init storybook UI on app startup and returns component ready, but dont display yet | |
*/ | |
export const initStorybookUI = (): React.ComponentType | null => { | |
if (!__DEV__) { | |
return null; | |
} | |
const PORT = 7007; | |
const HOST = getConfig().reactNativeHostIP || ''; | |
console.log( | |
`Init Storybook with ${ | |
allStories.length | |
} stories on http://${HOST}:${PORT.toString()}`, | |
); | |
// load the stories in | |
configure(() => { | |
loadStories(); | |
}, module); | |
return getStorybookUI({ | |
port: PORT, | |
onDeviceUI: false, | |
host: HOST, | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment