mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-19 05:02:40 +08:00
Use RN packager host by default in examples and also CLI templates
This commit is contained in:
parent
aebecbe00d
commit
8f10fce540
@ -59,6 +59,7 @@
|
||||
"react-native-compat": "0.0.2",
|
||||
"shelljs": "^0.7.8",
|
||||
"style-loader": "^0.17.0",
|
||||
"url-parse": "^1.1.9",
|
||||
"url-loader": "^0.5.8",
|
||||
"util-deprecate": "^1.0.2",
|
||||
"uuid": "^3.1.0",
|
||||
|
5
app/react-native/src/preview/index.js
vendored
5
app/react-native/src/preview/index.js
vendored
@ -1,6 +1,8 @@
|
||||
/* eslint no-underscore-dangle: 0 */
|
||||
|
||||
import React from 'react';
|
||||
import { NativeModules } from 'react-native';
|
||||
import parse from 'url-parse';
|
||||
import addons from '@storybook/addons';
|
||||
import createChannel from '@storybook/channel-websocket';
|
||||
import { EventEmitter } from 'events';
|
||||
@ -55,8 +57,7 @@ export default class Preview {
|
||||
let webUrl = null;
|
||||
let channel = addons.getChannel();
|
||||
if (params.resetStorybook || !channel) {
|
||||
const host = params.host || 'localhost';
|
||||
|
||||
const host = params.host || parse(NativeModules.SourceCode.scriptURL).hostname;
|
||||
const port = params.port !== false ? `:${params.port || 7007}` : '';
|
||||
|
||||
const query = params.query || '';
|
||||
|
@ -10,9 +10,8 @@ configure(() => {
|
||||
|
||||
const StorybookUI = getStorybookUI({
|
||||
port: 7007,
|
||||
host: 'localhost',
|
||||
// host: 'localhost',
|
||||
onDeviceUI: true,
|
||||
resetStorybook: true,
|
||||
});
|
||||
|
||||
setTimeout(
|
||||
|
@ -8,6 +8,8 @@ configure(() => {
|
||||
require('./stories');
|
||||
}, module);
|
||||
|
||||
const StorybookUI = getStorybookUI({ port: 7007, host: 'localhost' });
|
||||
// This assumes that storybook is running on the same host as your RN packager,
|
||||
// to set manually use, e.g. host: 'localhost' option
|
||||
const StorybookUI = getStorybookUI({ port: 7007 });
|
||||
AppRegistry.registerComponent('%APP_NAME%', () => StorybookUI);
|
||||
export default StorybookUI;
|
||||
|
@ -5,5 +5,7 @@ configure(() => {
|
||||
require('./stories');
|
||||
}, module);
|
||||
|
||||
const StorybookUI = getStorybookUI({ port: 7007, host: 'localhost' });
|
||||
// This assumes that storybook is running on the same host as your RN packager,
|
||||
// to set manually use, e.g. host: 'localhost' option
|
||||
const StorybookUI = getStorybookUI({ port: 7007 });
|
||||
export default StorybookUI;
|
||||
|
Loading…
x
Reference in New Issue
Block a user