【发布时间】:2021-06-17 10:46:39
【问题描述】:
我已经开始在我的一个应用程序中使用 Storybook for 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;
这里是 rn 附加组件,这些已经包含在内。
import '@storybook/addon-ondevice-actions/register';
import '@storybook/addon-ondevice-knobs/register';
这些是一些按钮组件的故事(将省略一些代码)
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" />);
仅供参考,这是我访问localhost:7007时浏览器选项卡的外观(与终端输出匹配,此站点的控制台没有输出任何错误)
我已经尝试过这个解决方案:https://github.com/storybookjs/react-native/issues/55#issuecomment-640164800
【问题讨论】:
标签: javascript reactjs react-native storybook