-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Conversation
examples/crna-kitchen-sink/App.js
Outdated
@@ -0,0 +1,25 @@ | |||
export default from './storybook'; | |||
|
|||
// import React from 'react'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also unsureFWIW
There was a problem hiding this comment.
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 😕
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 🙇
There was a problem hiding this comment.
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 Report
@@ 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
Continue to review full report at Codecov.
|
There was a problem hiding this 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 👍
@@ -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; |
There was a problem hiding this comment.
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}` : ''; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Issue: #1222
What I did
Use the RN packager's host by default as described in #1222
How to test
First:
Then test RN:
Then test CNRA: