Use RN packager host by default in examples and also CLI templates

This commit is contained in:
Michael Shilman 2017-08-01 11:13:11 -07:00
parent aebecbe00d
commit 8f10fce540
5 changed files with 11 additions and 6 deletions

View File

@ -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",

View File

@ -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 || '';

View File

@ -10,9 +10,8 @@ configure(() => {
const StorybookUI = getStorybookUI({
port: 7007,
host: 'localhost',
// host: 'localhost',
onDeviceUI: true,
resetStorybook: true,
});
setTimeout(

View File

@ -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;

View File

@ -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;