react-windowed-select: react-windowed-select crashes Next.js
This package is broken on Next.js.
To reproduce:
- Create a Next.js app using
create-next-app
or by hand npm i react-windowed-select
- Add a WindowedSelect to any page
A TypeError: Cannot read property 'registered' of null
is thrown.
Here’s a minimal reproduction - a Next.js app which is empty besides a single WindowedSelect on the homepage.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 17 (3 by maintainers)
I actually think it is a packaging issue @jacobworrel, I ended up solving this for me by vendoring in your code. Yes, literally copied the typescript source into my project to avoid going through webpack.
It did the trick.
I’m not entirely sure how packages get compiled and included into a next.js project.
@jacobworrel I was investigating this issue today, and it turned out that this line causes the error. I’m not an expert in Emotion, but I’ve found a workaround - it’s to add
react-select
toexternals
inwebpack.config.js
.I forgot to follow up on my question, I had to modify the typescript config file with the one from this code to get it to be happy with it. 😃
Is it working for you during deployment? It works fine on my dev setup, but once I deploy on Vercel I get the following :
Failed to compile. ./components/react-windowed-select/MenuList.tsx:10:23 Type error: Module ‘“react-select”’ has no exported member ‘GroupTypeBase’. Did you mean to use ‘import GroupTypeBase from “react-select”’ instead? 8 | import * as React from ‘react’; 9 | import { ListChildComponentProps, VariableSizeList as List } from ‘react-window’; 10 | import { OptionProps, GroupTypeBase, OptionTypeBase } from ‘react-select’;`
11 | 12 | interface Style extends React.CSSProperties { 13 | top: number, Error: Command “npm run build” exited with 1
Thanks Jacob, no worries thanks for putting up this library 😁. Open Source is a lot of hard work ❤️
Had to enable Typescript for the project.-> touch tsconfig.json in root folder
Thanks for the workaround @yagudaev 😃 Unfortunately, I don’t have time at the moment to fix the underlying packaging issue but if anyone in this thread wants to submit a PR so that the package can be consumed in next.js projects, that would be very welcome!
@yagudaev Thank you 😃 It is working
@aaqibqadeer I literally went to master source, copied and pasted the files I needed from there in typescript into my project.
I put all that into a special folder called
/src/vendor/react-windowed-select
Code works fine, just something with the build