[5.0.0] Build error in src/components/Menu.tsx
See original GitHub issueI’m encountering the above error when attempting to build any project with v5.0.0 of react-select
, which looks to be caused by the following line in src/components/Menu.tsx
:
context!: ContextType<typeof PortalPlacementContext>;
The documentation of Component
states the following:
* If using the new style context, re-declare this in your class to be the
* `React.ContextType` of your `static contextType`.
* Should be used with type annotation or static contextType.
*
* ```ts
* static contextType = MyContext
* // For TS pre-3.7:
* context!: React.ContextType<typeof MyContext>
* // For TS 3.7 and above:
* declare context: React.ContextType<typeof MyContext>
The current code that’s causing the error looks like it was intended for use in TS pre-3.7, but react-select
currently depends on version ^4.1.3
of typescript
.
I’m not much of a web developer, but it looks like the proper solution is to replace the problematic line with the following:
declare context: ContextType<typeof PortalPlacementContext>;
If it would be helpful, I’m happy to open a pull request to fix this issue.
Thanks!
Edit: The version of React in my project is 17.0.2
, whereas react-select
depends on version ^16.13.0
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
Error: 'node-sass' version 5.0.0 is incompatible with ^4.0.0
Workaround: don't install node-sass 5.0.0 yet (the major version was just bumped). Uninstall node-sass. npm uninstall node-sass. Then install ...
Read more >CRA 5.0.0 breaks build : r/reactjs - Reddit
I've an old React app, now dependent on react-scripts@4.0.3. It contains several .test.tsx files for tests. Some of these test files contain ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I updated
react-select-async-paginate
to the latest version (0.6.0
), and that seemed to fix the issue.I apologize for the inconvenience!
I did some digging and I think I found the problem in another project ours depends on, so false alarm. Sorry for the trouble.