Jer*_*emy 5 javascript reactjs react-native storybook
我已经开始在我的一个应用程序中使用 React Native 的故事书,它对我帮助很大,但似乎用于在组件之间导航的侧边栏被卡住加载(向我显示骨架动画)。我还尝试在新的 React Native 应用程序上运行故事书,但问题仍然存在(仅在 Android 上测试)。
这是 stpries UI 的索引文件
// if you use expo remove this line
import {AppRegistry} from 'react-native';
import {getStorybookUI, configure, addDecorator} from '@storybook/react-native';
import {withKnobs} from '@storybook/addon-knobs';
import './rn-addons';
// enables knobs for all stories
addDecorator(withKnobs);
// import stories
configure(() => {
require('../src/components/Stories/Button.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({});
// 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 should remove this line.
AppRegistry.registerComponent('%APP_NAME%', () => StorybookUIRoot);
export default StorybookUIRoot;
Run Code Online (Sandbox Code Playgroud)
这是 rn 附加组件,这些附加组件已经包含在内。
import '@storybook/addon-ondevice-actions/register';
import '@storybook/addon-ondevice-knobs/register';
Run Code Online (Sandbox Code Playgroud)
这些是一些按钮组件的故事(将省略一些代码)
import * as React from 'react';
import {storiesOf} from '@storybook/react-native';
import {BufferView} from './decorators';
import BeexButton from '../Buttons/BeexButton';
import SocialButton from '../Buttons/SocialButton';
storiesOf('Button', module)
.addDecorator(BufferView)
.add('default primary', () => <BeexButton text="Primary Button" />);
Run Code Online (Sandbox Code Playgroud)
仅供参考,这是我访问时浏览器选项卡的外观localhost:7007(这与终端输出匹配,并且该站点的控制台不会输出任何错误)
我已经尝试过这个解决方案:https://github.com/storybookjs/react-native/issues/55#issuecomment-640164800
我设法通过改变来解决这个问题index.js
// storybook/index.js
const StorybookUIRoot = getStorybookUI({
// Add the line below
host: Platform.OS === 'android' ? '10.0.2.2' : '0.0.0.0'
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1878 次 |
| 最近记录: |