🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

react-native-device-preview

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-device-preview

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](#)

0.0.17
latest
npm
Version published
Weekly downloads
9
-80.43%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-device-preview

License: MIT

Component preview for react native.

Install

yarn add react-native-device-preview

Setup

yarn rn-dp-init

Usage

Add the next scripts in package.json


{
    ...
    "scripts": {
        ....
        "get-stories": "rn-dp-get-stories",
        "watch-stories": "rn-dp-watcher",
        "prestart": "rn-dp-get-stories"
        ....
    }
    ...
}

In your App.js

import { StorybookRootUI } from './.storybook/storybook-ui-root'

function App() {
  return <StorybookRootUI />
}

export default App

Start developing

yarn start
yarn ios
yarn android

Custom components directory

Change the stories path in .storybook/main.js with your components path

module.exports = {
  stories: ['../src/components/**/*.stories.?(ts|tsx|js|jsx)'],
}

Create your components and stories

    |- src/components
        |- button.js
        |- button.stories.js
// button.js
import { Button as RNButton } from 'react-native'

export const Button = ({ title }) => {
  return <RNButton title={title} />
}
// button.stories.js
import { Button } from './button'

export default {
  title: 'button',
  component: Button,
}

const Template = args => <Button {...args} />

export const Default = Template.bind({})

Default.args = {
  title: 'button',
}

Typescript support

// button.tsx
import { Button as RNButton } from 'react-native'

export const Button = ({ title }: { title: string }) => {
  return <RNButton title={title} />
}
// button.stories.tsx
import { ComponentMeta, ComponentStory } from 'react-native-device-preview'
import { Button } from './button'

export default {
  title: 'button',
  component: Button,
} as ComponentMeta<typeof Button>

const Template: ComponentStory<typeof Button> = args => <Button {...args} />

export const Default = Template.bind({})

Default.args = {
  title: 'button',
}

License

MIT

FAQs

Package last updated on 12 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts