question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[5.0.0] Build error in src/components/Menu.tsx

See original GitHub issue

image

I’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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

3reactions
jhg023commented, Oct 4, 2021

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!

1reaction
sallakoscommented, Oct 4, 2021

I did some digging and I think I found the problem in another project ours depends on, so false alarm. Sorry for the trouble.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found