React native 在react native中启动多个应用程序
我正在尝试为storybook创建一个dev菜单按钮,例如React native 在react native中启动多个应用程序,react-native,React Native,我正在尝试为storybook创建一个dev菜单按钮,例如 if(\uuu DEV\uuu){ const DevMenu=require('react-native-dev-menu'); 让IsToryBook=false; DevMenu.addItem('Toggle Storybook',()=>{ 如果(IStorybook){ AppRegistry.unununapplicationComponentAtrottag( AppRegistry.getAppKeys()?.inde
if(\uuu DEV\uuu){
const DevMenu=require('react-native-dev-menu');
让IsToryBook=false;
DevMenu.addItem('Toggle Storybook',()=>{
如果(IStorybook){
AppRegistry.unununapplicationComponentAtrottag(
AppRegistry.getAppKeys()?.indexOf('故事书')
);
renderApp();
}否则{
配置(()=>{
require('./src/stories.tsx');//我们将在接下来的步骤中创建此文件
},模块);
const-StorybookUIRoot=getStorybookUI({});
AppRegistry.unununapplicationComponentAtrottag(
AppRegistry.getAppKeys()?.indexOf(appName)
);
AppRegistry.registerComponent('Storybook',()=>StorybookUIRoot);
}
isStorybook=!isStorybook;
});
}
预期结果是在storybook应用程序和实际应用程序之间切换。
实际发生的是故事书代码运行(我得到了与故事书相关的警告),但主应用程序仍然显示
没有这个设置,只需运行constStoryBookUIRoot=getStorybookUI({});AppRegistry.registerComponent('Storybook',()=>StorybookUIRoot)代码>有效,所以这不是故事书,而是我尝试加载和卸载应用程序的方式是错误的