All Projects → javidjamae → expo-with-storybook-howto

javidjamae / expo-with-storybook-howto

Licence: other
How to setup an Expo-based React Native project to use Storybook

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to expo-with-storybook-howto

React Native
📓 Storybook for React Native!
Stars: ✭ 222 (+441.46%)
Mutual labels:  storybook, expo
clockface
UI Kit for building Chronograf
Stars: ✭ 33 (-19.51%)
Mutual labels:  storybook
react-native-tablets
Scaling React Native Apps for Tablets 🎉
Stars: ✭ 13 (-68.29%)
Mutual labels:  expo
uzual-mobile
Feed your brains with habits for a better mood
Stars: ✭ 67 (+63.41%)
Mutual labels:  expo
react-native-mobx-feathers
A basic App using react-navigation + mobx + feathers
Stars: ✭ 31 (-24.39%)
Mutual labels:  expo
vuetibook
Integrating Vue.js, Vuetify and Storybook
Stars: ✭ 16 (-60.98%)
Mutual labels:  storybook
react-native-fashion
Fashion inspiration and shopping app helping you wear that's in style. Made with Typescript & ReactNative.
Stars: ✭ 47 (+14.63%)
Mutual labels:  expo
boilerplate
Fullstack boilerplate using Typescript, React, Node & GraphQL
Stars: ✭ 738 (+1700%)
Mutual labels:  expo
elements
Lovingly crafted ui components based on web components. Works well with all Frameworks - including Angular, React and Vue.
Stars: ✭ 42 (+2.44%)
Mutual labels:  storybook
react-universal
Minimal React+Redux boilerplate for web, mobile, and desktop app development with social-login ready
Stars: ✭ 18 (-56.1%)
Mutual labels:  expo
expo-three-orbit-controls
🎥 Three.js Orbit Controls (Camera) bridged into React Native
Stars: ✭ 43 (+4.88%)
Mutual labels:  expo
elm-book
Rich documentation builder for Elm applications and packages. Inspired by Storybook and HexDocs.
Stars: ✭ 52 (+26.83%)
Mutual labels:  storybook
stencil-storybook
Storybook meets Stencil in 2021
Stars: ✭ 66 (+60.98%)
Mutual labels:  storybook
storybook-addon-intl
Addon to provide a locale switcher and react-intl for storybook
Stars: ✭ 84 (+104.88%)
Mutual labels:  storybook
react-activity-calendar
A React component to display activity data in a calendar (heatmap)
Stars: ✭ 69 (+68.29%)
Mutual labels:  storybook
killer-storybook-config
A killer Storybook Webpack config to help you bootstrap a great storybook config ASAP. It includes a React Frontend, GraphQL compatibility for Storybook, TypeScript, Babel, and ESlint.
Stars: ✭ 32 (-21.95%)
Mutual labels:  storybook
react-flappy-bird
A side-scroller where the player controls a bird, attempting to fly between columns of green pipes without hitting them.
Stars: ✭ 55 (+34.15%)
Mutual labels:  expo
outline
Outline is a web component based design system starter kit. Outline is based on the latest technologies and tools to help your component authoring experience and facilitate adoption in your organization.
Stars: ✭ 28 (-31.71%)
Mutual labels:  storybook
react-native-expo-starter-kit
🚀 A React Native (Expo) boilerplate app to get you up and running very, very quickly 🚀
Stars: ✭ 66 (+60.98%)
Mutual labels:  expo
react-native-tap-tile-game
An awesome TapTile Game built usign create-react-native-app
Stars: ✭ 44 (+7.32%)
Mutual labels:  expo

Expo with Storybook

Expo is a great tool for building React Native app. Storybook is a great tool for building and testing view components. This README describes the steps necessary to get these two great tools to work together. This repository contains the final product of running through these steps.

Create a new Expo project:

$ exp init expo-with-storybook-howto
? Choose a template type: blank
[exp] Downloading project files...
[exp] Extracting project files...
[exp] Customizing project...
[exp] Starting project...
[exp] Your project is ready at /blah/expo-with-storybook-howto. Use "exp start /blah/expo-with-storybook-howto" to get started.

Install dependencies

$ npm i --save-dev @storybook/react-native exp [email protected] concurrently
$ npm i --save react-native-vector-icons

Add scripts to package.json

"scripts": {
  "storybook": "concurrently --kill-others \"storybook start -p 19001\" \"exp start --http\""
},

Make a directory for Storybook

$ mkdir storybook

Create Storybook files:

Create a file called storybook/index.js:

import { getStorybookUI, configure } from '@storybook/react-native'
import React from 'react'
import { NativeModules } from 'react-native'
import url from 'url'

import '@storybook/addon-actions/register'

configure( () => {
  require('./stories')
}, module )

const { hostname } = url.parse( NativeModules.SourceCode.scriptURL )

const StorybookUI = getStorybookUI( { port: 19001, host: hostname } )

export default StorybookUI

Create a new file called storybook/stories.js:

import '../src/components/Button.stories'

Create a component

$ mkdir -p src/components

In this example, I created src/components/Button.js

Create a story for the component

In this example, I created src/components/Button.stories.js, which looks like this:

import React from 'react'
import { storiesOf } from '@storybook/react-native'

import Button from './Button'

storiesOf('components/Button', module).add('with Text', () =>
  <Button>
    Text
  </Button>
)

storiesOf('components/Button', module).add('with Text2', () =>
  <Button>
    Text2
  </Button>
)

Move app entry point into src folder

$ mv App.js src/index.js

Create a new app entry point

Create a new /App.js that looks like this:

export default (__DEV__
  ? require('./storybook').default
  : require('./src').defaut);

In my opinion, this is not the ideal way to set it up in a real app, because it will always display Storybook on your local machine and you can only see the real app when you build / publish to expo.

According to the documentation:

Alternatively, StorybookUI is simply a RN View component that can be embedded anywhere in your RN application, e.g. on a tab or within an admin screen.

Start Storybook and the simulator

$ npm run storybook

Go to http://localhost:19001/

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].