Skip to content

Commit

Permalink
feat: some improvements to using facing api
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyhw committed May 30, 2021
1 parent 99bce77 commit c431ff6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/react-native/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const paths = ${path_array_str}
const getCSFStories=() => {
return paths.filter((exports) => !!exports.default?.title);
}
configure("react-native", getCSFStories, module, true)
configure(getCSFStories, module, false)
`;

Expand Down
12 changes: 4 additions & 8 deletions app/react-native/src/preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { addons } from '@storybook/addons';
import Channel from '@storybook/channels';
import { ClientApi, ConfigApi, StoryStore } from '@storybook/client-api';
import { loadCsf } from '@storybook/core-client/dist/modern/preview/loadCsf';
import { Loadable } from '@storybook/core-client';
import { loadCsf } from '@storybook/core-client/dist/modern/preview/loadCsf';
import Events from '@storybook/core-events';
import { ThemeProvider } from 'emotion-theming';
import React from 'react';
Expand Down Expand Up @@ -51,12 +51,7 @@ export default class Preview {

_configApi: ConfigApi;

configure: (
framework: string,
loadable: Loadable,
m: NodeModule,
showDeprecationWarning: boolean
) => void;
configure: (loadable: Loadable, m: NodeModule, showDeprecationWarning: boolean) => void;

constructor() {
const channel = new Channel({ async: true });
Expand All @@ -65,11 +60,12 @@ export default class Preview {
this._clientApi = new ClientApi({ storyStore: this._storyStore });
this._configApi = new ConfigApi({ storyStore: this._storyStore });
this._channel = channel;
this.configure = loadCsf({
const configure = loadCsf({
clientApi: this._clientApi,
storyStore: this._storyStore,
configApi: this._configApi,
});
this.configure = (...args) => configure('react-native', ...args);

addons.setChannel(channel);
}
Expand Down
5 changes: 4 additions & 1 deletion examples/native/Storybook.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// @ts-ignore
import AsyncStorage from '@react-native-async-storage/async-storage';
import { getStorybookUI } from '@storybook/react-native';

import './storybook.requires';

const StorybookUIRoot = getStorybookUI({
asyncStorage: null,
asyncStorage: AsyncStorage,
});

export default StorybookUIRoot;
3 changes: 3 additions & 0 deletions examples/native/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ DEPENDENCIES:
- React-RCTVibration (from `../../../node_modules/react-native/Libraries/Vibration`)
- React-runtimeexecutor (from `../../../node_modules/react-native/ReactCommon/runtimeexecutor`)
- ReactCommon/turbomodule/core (from `../../../node_modules/react-native/ReactCommon`)
- "RNCAsyncStorage (from `../../../node_modules/@react-native-async-storage/async-storage`)"
- Yoga (from `../../../node_modules/react-native/ReactCommon/yoga`)

SPEC REPOS:
Expand Down Expand Up @@ -443,6 +444,8 @@ EXTERNAL SOURCES:
:path: "../../../node_modules/react-native/ReactCommon/runtimeexecutor"
ReactCommon:
:path: "../../../node_modules/react-native/ReactCommon"
RNCAsyncStorage:
:path: "../../../node_modules/@react-native-async-storage/async-storage"
Yoga:
:path: "../../../node_modules/react-native/ReactCommon/yoga"

Expand Down
1 change: 1 addition & 0 deletions examples/native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"preset": "react-native"
},
"dependencies": {
"@react-native-async-storage/async-storage": "^1.15.4",
"@storybook/addon-actions": "6.3.0-alpha.33",
"@storybook/addon-links": "6.3.0-alpha.33",
"@storybook/addons": "6.3.0-alpha.33",
Expand Down
14 changes: 14 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3928,6 +3928,13 @@
prop-types "^15.6.1"
react-lifecycles-compat "^3.0.4"

"@react-native-async-storage/async-storage@^1.15.4":
version "1.15.4"
resolved "https://registry.yarnpkg.com/@react-native-async-storage/async-storage/-/async-storage-1.15.4.tgz#cdba464ca3bb9f10ec538342cbf2520c06f453ab"
integrity sha512-pC0MS6UBuv/YiVAxtzi7CgUed8oCQNYMtGt0yb/I9fI/BWTiJK5cj4YtW2XtL95K5IuvPX/6uGWaouZ8KqXwdg==
dependencies:
deep-assign "^3.0.0"

"@react-native-community/cli-debugger-ui@^5.0.1-alpha.1":
version "5.0.1-alpha.1"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-debugger-ui/-/cli-debugger-ui-5.0.1-alpha.1.tgz#09a856ccd2954cf16eea59b14dd26ae66720e4e6"
Expand Down Expand Up @@ -8765,6 +8772,13 @@ dedent@^0.7.0:
resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c"
integrity sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=

deep-assign@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/deep-assign/-/deep-assign-3.0.0.tgz#c8e4c4d401cba25550a2f0f486a2e75bc5f219a2"
integrity sha512-YX2i9XjJ7h5q/aQ/IM9PEwEnDqETAIYbggmdDB3HLTlSgo1CxPsj6pvhPG68rq6SVE0+p+6Ywsm5fTYNrYtBWw==
dependencies:
is-obj "^1.0.0"

deep-equal-ident@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/deep-equal-ident/-/deep-equal-ident-1.1.1.tgz#06f4b89e53710cd6cea4a7781c7a956642de8dc9"
Expand Down

0 comments on commit c431ff6

Please sign in to comment.