How to use the @storybook/react-native.addDecorator function in @storybook/react-native

To help you get started, we’ve selected a few @storybook/react-native examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anarock / pebble-native / storybook / storybook.tsx View on Github external
import * as React from "react";
import { AppRegistry } from "react-native";
import {
  getStorybookUI,
  configure,
  addDecorator
} from "@storybook/react-native";
import { withKnobs } from "@storybook/addon-knobs";

addDecorator(withKnobs);

// import stories
configure(() => {
  require("./stories");
}, module);

// This assumes that storybook is running on the same host as your RN packager,
// to set manually use, e.g. host: 'localhost' option
const StorybookUIRoot = getStorybookUI({ port: 7007, onDeviceUI: true });

import "./rn-addons";

// react-native hot module loader must take in a Class - https://github.com/facebook/react-native/issues/10991
// https://github.com/storybooks/storybook/issues/2081
// eslint-disable-next-line react/prefer-stateless-function
class StorybookUIHMRRoot extends React.Component {
github dooboolab / dooboo-ui-native / storybook / index.js View on Github external
import { withKnobs } from '@storybook/addon-knobs';

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

// Refer to https://github.com/storybookjs/storybook/tree/master/app/react-native#start-command-parameters
// To find allowed options for getStorybookUI
const StorybookUIRoot = getStorybookUI({ port: 7007, host: 'localhost' });

// If you are using React Native vanilla and after installation you don't see your app name here, write it manually.
// If you use Expo you can safely remove this line.
AppRegistry.registerComponent('%APP_NAME%', () => StorybookUIRoot);

addDecorator(withKnobs);

export default StorybookUIRoot;
github wheatandcat / Peperomia / PeperomiaNative / storybook / index.js View on Github external
addDecorator
} from "@storybook/react-native";
import { AppearanceProvider } from "react-native-appearance";
import ThemeProvider from "../src/containers/Theme.tsx";
import { loadStories } from "./storyLoader";
import "./rn-addons";

export const provider = story => (
  
    
      {story()}
    
  
);

addDecorator(provider);

configure(() => {
  loadStories();
}, module);

// Refer to https://github.com/storybooks/storybook/tree/master/app/react-native#start-command-parameters
// To find allowed options for getStorybookUI
const StorybookUIRoot = getStorybookUI({});

export default StorybookUIRoot;
github echobind / react-native-template / template / storybook / storybook.js View on Github external
import { name as appName } from '../app.json';
import { Container } from '../src/components/Container';

// addons!
import './rn-addons';

// adding a centered-view layout!
const CenterView = ({ children }) => (
  
    {children}
  
);

// global decorators!
addDecorator(getStory => {getStory()});
addDecorator(withBackgrounds);
addParameters({
  backgrounds: [
    { name: 'light', value: '#fff', default: true },
    { name: 'gray', value: '#808080' },
    { name: 'dark', value: '#000' },
  ],
});

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

// Refer to https://github.com/storybookjs/storybook/tree/master/app/react-native#start-command-parameters
// To find allowed options for getStorybookUI
const StorybookUIRoot = getStorybookUI({});
github appbaseio / reactivesearch / packages / native / example / storybook / index.js View on Github external
/* eslint-disable global-require */
import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import { getStorybookUI, configure, addDecorator } from '@storybook/react-native';
import { withKnobs } from '@storybook/addon-knobs';

import Container from './stories/Container';

addDecorator(story => );
addDecorator(withKnobs);

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

// This assumes that storybook is running on the same host as your RN packager,
// to set manually use, e.g. host: 'localhost' option
const StorybookUIRoot = getStorybookUI({ port: 7007, onDeviceUI: true });

// react-native hot module loader must take in a Class - https://github.com/facebook/react-native/issues/10991
// https://github.com/storybooks/storybook/issues/2081
// eslint-disable-next-line react/prefer-stateless-function
class StorybookUIHMRRoot extends Component {
	render() {
		return ;
github wheatandcat / Peperomia / ShioriNative / storybook / storybook.js View on Github external
import React from "react";
import { ActionSheetProvider } from "@expo/react-native-action-sheet";
import {
  getStorybookUI,
  configure,
  addDecorator
} from "@storybook/react-native";
import { loadStories } from "./storyLoader";

export const provider = story => (
  {story()}
);

addDecorator(provider);

configure(() => {
  loadStories();
}, module);

const StorybookUI = getStorybookUI({ port: 7007, host: "localhost" });
export default StorybookUI;
github storybookjs / storybook / examples-native / crna-kitchen-sink / storybook / stories / index.js View on Github external
import React from 'react';
import { Text } from 'react-native';

import { storiesOf, addDecorator, addParameters } from '@storybook/react-native';
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';
import { withKnobs } from '@storybook/addon-knobs';
import { withBackgrounds } from '@storybook/addon-ondevice-backgrounds';
import knobsWrapper from './Knobs';
import Button from './Button';
import CenterView from './CenterView';
import Welcome from './Welcome';

addDecorator(withBackgrounds);

addParameters({
  backgrounds: [
    { name: 'dark', value: '#222222' },
    { name: 'white', value: '#ffffff', default: true },
  ],
});

storiesOf('Welcome', module).add('to Storybook', () => , {
  notes: `
# Markdown!\n
* List Item
* [List Item with Link](https://storybook.js.org)
`,
});
github orangeloops / public-ol-native-template / storybook / index.js View on Github external
configure(() => {
  addDecorator(withKnobs);

  let lastRender = null;
  const CommonStoryDecorator = ({story}) => {
    const [shouldRender, setShouldRender] = React.useState(false);

    React.useEffect(() => {
      const timeout = setTimeout(() => {
        setShouldRender(true);
      });

      return () => {
        clearTimeout(timeout);
        delete DataStore["instance"];
      };
    }, []);
github newsuk / times-components / storybook-native / storybook.js View on Github external
import { AppRegistry, NativeModules, Platform } from "react-native";
import {
  getStorybookUI,
  configure,
  addDecorator
} from "@storybook/react-native";
import { withKnobs } from "@storybook/addon-knobs";
import {
  BarSpacingDecorator,
  WhiteBgColorDecorator
} from "@times-components/storybook";
import { loadStories } from "./story-loader";
import "./rn-addons";

if (Platform.OS === "ios") {
  addDecorator(BarSpacingDecorator);
}

if (Platform.OS === "android") {
  addDecorator(WhiteBgColorDecorator);
}

addDecorator(withKnobs);

configure(loadStories, module);

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

const StorybookUIRoot = getStorybookUI({
  port: 7007,
  host: hostname
});
github loadsmart / blocks / StorybookUI.tsx View on Github external
import { configure, getStorybookUI, addDecorator } from '@storybook/react-native'
import { loadStories } from './storyLoader'

import './rn-addons'
import { withKnobs } from '@storybook/addon-knobs'

addDecorator(withKnobs)

const StorybookUI = getStorybookUI({ port: 9001, host: 'localhost' })

configure(() => {
  loadStories()
}, module)

export default StorybookUI