Skip to content

ZhengRui/sbv7-issue-repro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

To reproduce (commit e80a3d0)

  1. build the sdk
cd sdk
pnpm install
pnpm build
  1. start the storybook
cd storybook
pnpm install
pnpm storybook

it will show the following errors:

TypeError: Cannot read properties of null (reading 'useEffect')
    at useEffect (http://localhost:6006/vendors-sdk_node_modules_pnpm_react_18_2_0_node_modules_react_index_js-node_modules_pnpm_reac-415da3.iframe.bundle.js:1644:21)
    at o (http://localhost:6006/ExampleSDKComponent-stories.iframe.bundle.js:17:66)
    at renderWithHooks (http://localhost:6006/vendors-node_modules_pnpm_storybook_addon-essentials_7_0_12_react-dom_18_2_0_react_18_2_0_nod-70b296.iframe.bundle.js:41173:18)
    at mountIndeterminateComponent (http://localhost:6006/vendors-node_modules_pnpm_storybook_addon-essentials_7_0_12_react-dom_18_2_0_react_18_2_0_nod-70b296.iframe.bundle.js:44937:13)
    at beginWork (http://localhost:6006/vendors-node_modules_pnpm_storybook_addon-essentials_7_0_12_react-dom_18_2_0_react_18_2_0_nod-70b296.iframe.bundle.js:46450:16)
    at beginWork$1 (http://localhost:6006/vendors-node_modules_pnpm_storybook_addon-essentials_7_0_12_react-dom_18_2_0_react_18_2_0_nod-70b296.iframe.bundle.js:52289:14)
    at performUnitOfWork (http://localhost:6006/vendors-node_modules_pnpm_storybook_addon-essentials_7_0_12_react-dom_18_2_0_react_18_2_0_nod-70b296.iframe.bundle.js:51420:12)
    at workLoopSync (http://localhost:6006/vendors-node_modules_pnpm_storybook_addon-essentials_7_0_12_react-dom_18_2_0_react_18_2_0_nod-70b296.iframe.bundle.js:51329:5)
    at renderRootSync (http://localhost:6006/vendors-node_modules_pnpm_storybook_addon-essentials_7_0_12_react-dom_18_2_0_react_18_2_0_nod-70b296.iframe.bundle.js:51297:7)
    at recoverFromConcurrentError (http://localhost:6006/vendors-node_modules_pnpm_storybook_addon-essentials_7_0_12_react-dom_18_2_0_react_18_2_0_nod-70b296.iframe.bundle.js:50713:20)

To fix (commit c3b7457)

cd sdk
pnpm remove react react-dom
pnpm link ../storybook/node_modules/react

Note: the fix brings the question when developing the lib, how you know which app's react it should link to. This link hack seems only relate to storybook v7, for other apps that uses the lib e.g. nextapp, it doesn't matter whether/where to link react in the lib.

Surrender

Give up the idea of separating lib and storybook as two separate projects to simulate how lib is imported and used in dependee projects, it simply brings too much hassles from storybook v7.

Just make them a combo single project, so you don't have to deal with all the two version issues reported by sb.

About

storybook v7 + react 18 + pnpm + webpack5 's invalid hook call issue reproduction

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published