From 85857e0b1093d7987d13218171d71fb49f5177c5 Mon Sep 17 00:00:00 2001 From: Vanessa Yuen <6842965+vanessayuenn@users.noreply.github.com> Date: Tue, 30 Jan 2024 23:01:46 +0100 Subject: [PATCH] add "React peer dependency is no longer required" section to addon migration guide --- docs/addons/addon-migration-guide.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/addons/addon-migration-guide.md b/docs/addons/addon-migration-guide.md index 8d0087b4fb4a..4e10e1cee527 100644 --- a/docs/addons/addon-migration-guide.md +++ b/docs/addons/addon-migration-guide.md @@ -34,6 +34,15 @@ Please upgrade your addon to Node.js 18, as support for Node.js 16 has ended. UI injected into panels, tools, etc. by addons is now rendered with React 18. Also note that the `key` prop is no longer passed to the render function. +### React peer dependency is no longer required + +To remove your addon's peer dependency on React, and reduce its install size, do the following: + +1. Move `react`, `react-dom` and the globalized Storybook packages from `peerDependencies` to `devDependencies` +2. Add the list of globalized packages to the `externals` property in the `tsup` configuration, to ensure they are not part of the bundle. + +For an example, see [the updates we've made to the addon-kit](https://github.com/storybookjs/addon-kit/pull/60/files#diff-8fed899bdbc24789a7bb4973574e624ed6207c6ce572338bc3c3e117672b2a20). These changes are optional but recommended. + ### @storybook/components deprecations `Icons` component from `@storybook/components` is now deprecated in favor of [`@storybook/icons`](https://github.com/storybookjs/icons). Additionally, various `Button` component props are also deprecated, with alternatives provided.