DEV Community

Discussion on: Create a React component library with Vite and Typescript

Collapse
 
mohamedabusrea profile image
Mohamed Abusrea • Edited

Thank you for the great article. I'm facing an issue when adding an extenral library like antd or like szhsin/react-menu. I get this error:

TypeError: Cannot read properties of null (reading 'useState')
    at Object.useState (http://localhost:6006/@fs/Users/mohamedabusrea/Desktop/Workspace/component-library/dist/component-library.es.js?t=1665733637289:1628:29)
    at useTransition2 (http://localhost:6006/@fs/Users/mohamedabusrea/Desktop/Workspace/component-library/dist/component-library.es.js?t=1665733637289:36830:33)
    at useMenuState2 (http://localhost:6006/@fs/Users/mohamedabusrea/Desktop/Workspace/component-library/dist/component-library.es.js?t=1665733637289:36898:24)
    at useMenuStateAndFocus2 (http://localhost:6006/@fs/Users/mohamedabusrea/Desktop/Workspace/component-library/dist/component-library.es.js?t=1665733637289:36911:23)
    at Menu2 (http://localhost:6006/@fs/Users/mohamedabusrea/Desktop/Workspace/component-library/dist/component-library.es.js?t=1665733637289:36937:31)
    at renderWithHooks (http://localhost:6006/node_modules/.vite-storybook/deps/chunk-5LLNUTNH.js?v=f9c3babb:11763:26)
    at updateForwardRef (http://localhost:6006/node_modules/.vite-storybook/deps/chunk-5LLNUTNH.js?v=f9c3babb:13907:28)
    at beginWork (http://localhost:6006/node_modules/.vite-storybook/deps/chunk-5LLNUTNH.js?v=f9c3babb:15479:22)
    at beginWork$1 (http://localhost:6006/node_modules/.vite-storybook/deps/chunk-5LLNUTNH.js?v=f9c3babb:19248:22)
    at performUnitOfWork (http://localhost:6006/node_modules/.vite-storybook/deps/chunk-5LLNUTNH.js?v=f9c3babb:18693:20)
Enter fullscreen mode Exit fullscreen mode

any clue?

Collapse
 
nicolaserny profile image
Nicolas Erny

Hello, I've just tried to use react-menu without any trouble. I wonder if you have conflicts between multiple React versions locally. You can check with "yarn why react".

Collapse
 
mohamedalkhawam profile image
mohamedalkhawam

Hi Thanks for your article, but I do have the same issue

Uncaught TypeError: Cannot read properties of null (reading 'useState')
at Object.useState

I here is my "yarn why react".

info Has been hoisted to "react"
info This module exists because it's specified in "devDependencies".
info Disk size without dependencies: "388KB"
info Disk size with unique dependencies: "420KB"
info Disk size with transitive dependencies: "448KB"
info Number of shared dependencies: 2