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.

Unable to type onSelect prop for Select correctly

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

Add an onSelect prop to a <Select /> when using typescript.

What is expected?

That I am able to get proper types for the onSelect callback parameters.

What is actually happening?

both arguments get implicitly typed as any, even when trying to use the generics syntax <Select<ValueType, OptionType>></Select>, this syntax does however seem to apply to the filterOption callback which does get its params typed based on ValueType and OptionType.

Environment Info
antd 4.18.8
React react 17.0.2
System windows 10
Browser n/a

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
afc163commented, Nov 9, 2022

@DBSDs sure

1reaction
DBSDscommented, Nov 9, 2022

can i work on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript React <Select> onChange handler type error
Since MUI Select in not a real select element you will need to cast e.target.value using as Type and type the handler as...
Read more >
Unable to type in Input field issue in React [Solved] | bobbyhadz
The problem is that the input field has a value prop set, but it doesn't have an onChange prop that handles changes of...
Read more >
TypeScript - React Select
A flexible and beautiful Select Input control for ReactJS with multiselect ... If TypeScript can't detect what type this should be, it defaults...
Read more >
Accessibility - React
Keyboard focus and focus outline. Keyboard focus refers to the current element in the DOM that is selected to accept input from the...
Read more >
useForm - register - Simple React forms validation
This method allows you to register an input or select element and apply validation rules to React ... onChange prop to subscribe the...
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