Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the RN packager's host by default #1568

Merged
merged 4 commits into from
Aug 1, 2017
Merged

Conversation

shilman
Copy link
Member

@shilman shilman commented Aug 1, 2017

Issue: #1222

What I did

Use the RN packager's host by default as described in #1222

  • added CRNA example for testing
  • updated the CLI templates

How to test

First:

yarn && yarn bootstrap

Then test RN:

yarn bootstrap:react-native-vanilla
cd examples/react-native-vanilla
yarn storybook
./node_modules/.bin/react-native run-ios

Then test CNRA:

yarn bootstrap:crna-kitchen-sink
cd examples/crna-kitchen-sink
yarn storybook
yarn ios

@shilman shilman changed the title 1222 parse rn packager host Use the RN packager's host by default Aug 1, 2017
@@ -0,0 +1,25 @@
export default from './storybook';

// import React from 'react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this left here intentionally?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll add to the comment tho. 😄

@@ -10,9 +10,8 @@ configure(() => {

const StorybookUI = getStorybookUI({
port: 7007,
host: 'localhost',
// host: 'localhost',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be deleted.

};

showApp(event) {
event.preventDefault();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgive my ignorance, but why is preventDefault needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copypasta? i'm not sure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also unsureFWIW

Copy link
Member Author

@shilman shilman Aug 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's all over the code (part of the CLI boilerplate), so I propose we address it separately 😕

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not typically need to .preventDefault() in React Native. That said I don't see the showApp function used anywhere in this component... so couldn't this method just be removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although - this might be something CRNA related so if so, please ignore my thoughts on removing it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK OK looks like it isn't used so I'll remove across the board, test, and submit. Thanks 🙇

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On third thought, I think this is a separate issue. This used to be used to show off addon-links but was removed at some point. Opened: #1569

@codecov
Copy link

codecov bot commented Aug 1, 2017

Codecov Report

Merging #1568 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1568      +/-   ##
==========================================
- Coverage   20.43%   20.43%   -0.01%     
==========================================
  Files         241      241              
  Lines        5250     5252       +2     
  Branches      656      645      -11     
==========================================
  Hits         1073     1073              
- Misses       3661     3682      +21     
+ Partials      516      497      -19
Impacted Files Coverage Δ
app/react-native/src/preview/index.js 0% <0%> (ø) ⬆️
lib/ui/src/modules/ui/configs/handle_routing.js 28.94% <0%> (ø) ⬆️
app/react-native/src/bin/storybook-start.js 0% <0%> (ø) ⬆️
addons/notes/src/react.js 0% <0%> (ø) ⬆️
addons/knobs/src/KnobManager.js 35.41% <0%> (ø) ⬆️
lib/ui/src/modules/ui/routes.js 0% <0%> (ø) ⬆️
app/react/src/client/preview/element_check.js 41.17% <0%> (ø) ⬆️
app/react/src/client/preview/error_display.js 0% <0%> (ø) ⬆️
addons/info/src/components/markdown/htags.js 30% <0%> (ø) ⬆️
lib/ui/src/modules/ui/libs/filters.js 53.33% <0%> (ø) ⬆️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7cdc25a...67a7093. Read the comment docs.

Copy link
Member

@orta orta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the same code in our non-CRNA app, and everything was good:

import { NativeModules } from "react-native"
console.log(NativeModules.SourceCode.scriptURL)

And got http://localhost:8081/Example/Emission/index.ios.bundle?platform=ios&dev=true&hot=true

So this is fine for non-CRNA too 👍

@shilman shilman merged commit d7bc10d into master Aug 1, 2017
@shilman shilman deleted the 1222-parse-rn-packager-host branch August 1, 2017 19:41
@@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant - didn’t know this was an accessible thing

@@ -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}` : '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the port for the ReactNative packager? Or where storybooks web previewed will be binding to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the storybook port

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants