Skip to content

Commit d7bc10d

Browse files
authored
Merge pull request #1568 from storybooks/1222-parse-rn-packager-host
Use the RN packager's host by default
2 parents 7cdc25a + 67a7093 commit d7bc10d

File tree

24 files changed

+353
-6
lines changed

24 files changed

+353
-6
lines changed

app/react-native/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"react-native-compat": "0.0.2",
6060
"shelljs": "^0.7.8",
6161
"style-loader": "^0.17.0",
62+
"url-parse": "^1.1.9",
6263
"url-loader": "^0.5.8",
6364
"util-deprecate": "^1.0.2",
6465
"uuid": "^3.1.0",

app/react-native/src/preview/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* eslint no-underscore-dangle: 0 */
22

33
import React from 'react';
4+
import { NativeModules } from 'react-native';
5+
import parse from 'url-parse';
46
import addons from '@storybook/addons';
57
import createChannel from '@storybook/channel-websocket';
68
import { EventEmitter } from 'events';
@@ -55,8 +57,7 @@ export default class Preview {
5557
let webUrl = null;
5658
let channel = addons.getChannel();
5759
if (params.resetStorybook || !channel) {
58-
const host = params.host || 'localhost';
59-
60+
const host = params.host || parse(NativeModules.SourceCode.scriptURL).hostname;
6061
const port = params.port !== false ? `:${params.port || 7007}` : '';
6162

6263
const query = params.query || '';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": ["babel-preset-expo"],
3+
"env": {
4+
"development": {
5+
"plugins": ["transform-react-jsx-source"]
6+
}
7+
}
8+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore unexpected extra "@providesModule"
9+
.*/node_modules/.*/node_modules/fbjs/.*
10+
11+
; Ignore duplicate module providers
12+
; For RN Apps installed via npm, "Libraries" folder is inside
13+
; "node_modules/react-native" but in the source repo it is in the root
14+
.*/Libraries/react-native/React.js
15+
.*/Libraries/react-native/ReactNative.js
16+
17+
; Additional create-react-native-app ignores
18+
19+
; Ignore duplicate module providers
20+
.*/node_modules/fbemitter/lib/*
21+
22+
; Ignore misbehaving dev-dependencies
23+
.*/node_modules/xdl/build/*
24+
.*/node_modules/reqwest/tests/*
25+
26+
; Ignore missing expo-sdk dependencies (temporarily)
27+
; https://github.com/expo/expo/issues/162
28+
.*/node_modules/expo/src/*
29+
30+
; Ignore react-native-fbads dependency of the expo sdk
31+
.*/node_modules/react-native-fbads/*
32+
33+
[include]
34+
35+
[libs]
36+
node_modules/react-native/Libraries/react-native/react-native-interface.js
37+
node_modules/react-native/flow
38+
flow/
39+
40+
[options]
41+
module.system=haste
42+
43+
emoji=true
44+
45+
experimental.strict_type_args=true
46+
47+
munge_underscores=true
48+
49+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
50+
51+
suppress_type=$FlowIssue
52+
suppress_type=$FlowFixMe
53+
suppress_type=$FixMe
54+
55+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-7]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)
56+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-7]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)?:? #[0-9]+
57+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
58+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
59+
60+
unsafe.enable_getters_and_setters=true
61+
62+
[version]
63+
^0.47.0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
.expo/
3+
npm-debug.*
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

examples/crna-kitchen-sink/App.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export default from './storybook';
2+
3+
// NOTE: The code below is what CRNA generates out of the box. We currently
4+
// have no clever way of replacing this with Storybook's UI (Vanilla RN does!)
5+
// so for now we just replace the code outright. Keeping this here for clarity.
6+
//
7+
// import React from 'react';
8+
// import { StyleSheet, Text, View } from 'react-native';
9+
//
10+
// export default class App extends React.Component {
11+
// render() {
12+
// return (
13+
// <View style={styles.container}>
14+
// <Text>Open up App.js to start working on your app!</Text>
15+
// <Text>Changes you make will automatically reload.</Text>
16+
// <Text>Shake your phone to open the developer menu.</Text>
17+
// </View>
18+
// );
19+
// }
20+
// }
21+
//
22+
// const styles = StyleSheet.create({
23+
// container: {
24+
// flex: 1,
25+
// backgroundColor: '#fff',
26+
// alignItems: 'center',
27+
// justifyContent: 'center',
28+
// },
29+
// });
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import renderer from 'react-test-renderer';
2+
3+
import React from 'react';
4+
import App from './App';
5+
6+
it('renders without crashing', () => {
7+
const rendered = renderer.create(<App />).toJSON();
8+
expect(rendered).toBeTruthy();
9+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CRNA Kitchen Sink
2+
3+
This project was bootstrapped with [Create React Native App](https://github.com/react-community/create-react-native-app) and storybook using [getstorybook](https://www.npmjs.com/package/@storybook/cli).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"expo": {
3+
"sdkVersion": "19.0.0"
4+
}
5+
}

0 commit comments

Comments
 (0)