@storybook/react-native 8.3.1-beta.3 โ†’ 8.3.6-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -984,6 +984,10 @@ var View3 = class {
984
984
  this.createPreparedStoryMapping().then(() => {
985
985
  this._ready = true;
986
986
  setReady(true);
987
+ initialStory.then((st) => {
988
+ self._preview.selectionStore.selectionSpecifier = st;
989
+ self._preview.selectSpecifiedStory();
990
+ });
987
991
  }).catch((e) => console.error(e));
988
992
  self._setStory = (newStory) => {
989
993
  setContext(newStory);
@@ -1004,10 +1008,6 @@ var View3 = class {
1004
1008
  }
1005
1009
  };
1006
1010
  self._forceRerender = () => forceUpdate();
1007
- initialStory.then((st) => {
1008
- self._preview.selectionStore.selectionSpecifier = st;
1009
- self._preview.selectSpecifiedStory();
1010
- });
1011
1011
  }, []);
1012
1012
  const storyHash = (0, import_react4.useMemo)(() => {
1013
1013
  if (!ready) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-native",
3
- "version": "8.3.1-beta.3",
3
+ "version": "8.3.6-alpha.0",
4
4
  "description": "A better way to develop React Native Components for your app",
5
5
  "keywords": [
6
6
  "react",
@@ -39,12 +39,12 @@
39
39
  "test:ci": "jest"
40
40
  },
41
41
  "dependencies": {
42
- "@storybook/core": "^8.3.1",
42
+ "@storybook/core": "^8.3.5",
43
43
  "@storybook/csf": "^0.1.1",
44
44
  "@storybook/global": "^5.0.0",
45
- "@storybook/react": "^8.3.1",
46
- "@storybook/react-native-theming": "^8.3.1-beta.3",
47
- "@storybook/react-native-ui": "^8.3.1-beta.3",
45
+ "@storybook/react": "^8.3.5",
46
+ "@storybook/react-native-theming": "^8.3.6-alpha.0",
47
+ "@storybook/react-native-ui": "^8.3.6-alpha.0",
48
48
  "chokidar": "^3.5.1",
49
49
  "commander": "^8.2.0",
50
50
  "dedent": "^1.5.1",
@@ -54,7 +54,7 @@
54
54
  "react-native-swipe-gestures": "^1.0.5",
55
55
  "react-native-url-polyfill": "^2.0.0",
56
56
  "setimmediate": "^1.0.5",
57
- "storybook": "^8.3.1",
57
+ "storybook": "^8.3.5",
58
58
  "type-fest": "~2.19",
59
59
  "util": "^0.12.4",
60
60
  "ws": "^8.18.0"
@@ -82,5 +82,5 @@
82
82
  "publishConfig": {
83
83
  "access": "public"
84
84
  },
85
- "gitHead": "1b2c4446155e3ee8f21f237da93f81b445419158"
85
+ "gitHead": "d547241520afdd10adf217c42d4697dbfc4d50f1"
86
86
  }
package/readme.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Storybook for React Native
2
2
 
3
+ > [!IMPORTANT]
4
+ > This readme is in the process of being updated for v8 which is not yet released to stable, for v7 docs see the [v7.6 docs](https://github.com/storybookjs/react-native/tree/v7.6.20-stable).
5
+
3
6
  With Storybook for React Native you can design and develop individual React Native components without running your app.
4
7
 
5
8
  This readme is for the 8.3.1 version, you can find the 7.6 docs [here](https://github.com/storybookjs/react-native/tree/v7.6.20-stable).
@@ -8,11 +11,10 @@ If you are migrating from 7.6 to 8.3 you can find the migration guide [here](htt
8
11
 
9
12
  For more information about storybook visit: [storybook.js.org](https://storybook.js.org)
10
13
 
11
- > NOTE: `@storybook/react-native` requires atleast 8.3.1, if you install other storybook core packages they should be `^8.3.1` or newer.
12
-
13
- ![picture of storybook](https://github.com/user-attachments/assets/3162c051-e6bf-4d39-8ae2-da060e1f8b78)
14
+ > [!NOTE]
15
+ > `@storybook/react-native` requires atleast 8.3.1, if you install other storybook core packages they should be `^8.3.1` or newer.
14
16
 
15
- _Pictured is from the template mentioned in [getting started](#getting-started)_
17
+ ![picture of storybook](https://github.com/user-attachments/assets/cf98766d-8b90-44ab-b718-94ab16e63205)
16
18
 
17
19
  ## Table of contents
18
20
 
@@ -20,7 +22,9 @@ _Pictured is from the template mentioned in [getting started](#getting-started)_
20
22
  - ๐Ÿ“’ [Writing stories](#writing-stories)
21
23
  - ๐Ÿ”Œ [Addons](#addons)
22
24
  - ๐Ÿ“ฑ [Hide/Show Storybook](#hideshow-storybook)
25
+ - โš™๏ธ [withStorybook wrapper](#withstorybook-wrapper)
23
26
  - ๐Ÿ”ง [getStorybookUI](#getstorybookui-options)
27
+ - ๐Ÿงช [Using stories in unit tests](#using-stories-in-unit-tests)
24
28
  - ๐Ÿค [Contributing](#contributing)
25
29
  - โœจ [Examples](#examples)
26
30
 
@@ -28,7 +32,7 @@ _Pictured is from the template mentioned in [getting started](#getting-started)_
28
32
 
29
33
  ### New project
30
34
 
31
- There is some project boilerplate with `@storybook/react-native` and `@storybook/addons-react-native-web` both already configured with a simple example.
35
+ There is some project boilerplate with `@storybook/react-native` and `@storybook/addon-react-native-web` both already configured with a simple example.
32
36
 
33
37
  For expo you can use this [template](https://github.com/dannyhw/expo-template-storybook) with the following command
34
38
 
@@ -288,6 +292,74 @@ Some have opted to toggle the storybook component by using a custom option in th
288
292
  - [Heres an approach for react native cli](https://dev.to/dannyhw/multiple-entry-points-for-react-native-storybook-4dkp)
289
293
  - [Heres an article about how you can do it in expo](https://dev.to/dannyhw/how-to-swap-between-react-native-storybook-and-your-app-p3o)
290
294
 
295
+ ## withStorybook wrapper
296
+
297
+ `withStorybook` is a wrapper function to extend your [Metro config](https://metrobundler.dev/docs/configuration) for Storybook. It accepts your existing Metro config and an object of options for how Storybook should be started and configured.
298
+
299
+ ```js
300
+ // metro.config.js
301
+ const { getDefaultConfig } = require('expo/metro-config');
302
+ const withStorybook = require('@storybook/react-native/metro/withStorybook');
303
+
304
+ const defaultConfig = getDefaultConfig(__dirname);
305
+
306
+ module.exports = withStorybook(defaultConfig, {
307
+ enabled: true,
308
+ // See API section below for available options
309
+ });
310
+ ```
311
+
312
+ ### Options
313
+
314
+ #### enabled
315
+
316
+ Type: `boolean`, default: `true`
317
+
318
+ Determines whether the options specified are applied to the Metro config. This can be useful for project setups that use Metro both with and without Storybook and need to conditionally apply the options. In this example, it is made conditional using an environment variable:
319
+
320
+ ```js
321
+ // metro.config.js
322
+ const { getDefaultConfig } = require('expo/metro-config');
323
+ const withStorybook = require('@storybook/react-native/metro/withStorybook');
324
+
325
+ const defaultConfig = getDefaultConfig(__dirname);
326
+
327
+ module.exports = withStorybook(defaultConfig, {
328
+ enabled: process.env.WITH_STORYBOOK,
329
+ // ... other options
330
+ });
331
+ ```
332
+
333
+ #### useJs
334
+
335
+ Type: `boolean`, default: `false`
336
+
337
+ Generates the `.storybook/storybook.requires` file in JavaScript instead of TypeScript.
338
+
339
+ #### configPath
340
+
341
+ Type: `string`, default: `path.resolve(process.cwd(), './.storybook')`
342
+
343
+ The location of your Storybook configuration directory, which includes `main.ts` and other project-related files.
344
+
345
+ ### websockets
346
+
347
+ Type: `{ host: string?, port: number? }`, default: `undefined`
348
+
349
+ If specified, create a WebSocket server on startup. This allows you to sync up multiple devices to show the same story and [arg](https://storybook.js.org/docs/writing-stories/args) values connected to the story in the UI.
350
+
351
+ ### websockets.host
352
+
353
+ Type: `string`, default: `'localhost'`
354
+
355
+ The host on which to run the WebSocket, if specified.
356
+
357
+ ### websockets.port
358
+
359
+ Type: `number`, default: `7007`
360
+
361
+ The port on which to run the WebSocket, if specified.
362
+
291
363
  ## getStorybookUI options
292
364
 
293
365
  You can pass these parameters to getStorybookUI call in your storybook entry point:
@@ -320,6 +392,10 @@ You can pass these parameters to getStorybookUI call in your storybook entry poi
320
392
  }
321
393
  ```
322
394
 
395
+ ## Using stories in unit tests
396
+
397
+ Storybook provides testing utilities that allow you to reuse your stories in external test environments, such as Jest. This way you can write unit tests easier and reuse the setup which is already done in Storybook, but in your unit tests. You can find more information about it in the [portable stories section](./PORTABLE_STORIES.md).
398
+
323
399
  ## Contributing
324
400
 
325
401
  We welcome contributions to Storybook!
@@ -13,7 +13,7 @@ const meta = {
13
13
  },
14
14
  decorators: [
15
15
  (Story) => (
16
- <View style={{ alignItems: 'center', justifyContent: 'center', flex: 1 }}>
16
+ <View style={{ padding: 16, alignItems: 'flex-start' }}>
17
17
  <Story />
18
18
  </View>
19
19
  ),