Skip to content

How to type 'option' in ControlledSelect's 'value' and 'onChange' when returning only selected value? #175

Answered by csandman
lucasrabiec asked this question in Q&A
Discussion options

You must be logged in to vote

First I'd recommend checking out the react-hook-form section of the docs, as there are a bunch of examples there for multiple scenarios in JS and TS.

This example specifically has a single select made as a custom component for react-hook-form in a TS app: https://codesandbox.io/s/chakra-react-select-single-react-hook-form-with-yup-validation-typescript-phmv0u?file=/components/controlled-select.tsx

If there is anything about this example that doesn't fit your needs, let me know and I can try and make it more specific!


EDIT:

Ok based on your extra input I made a new example showing how you could do it with only the value. There are two main points to this change. The first is making sure the

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@csandman
Comment options

@lucasrabiec
Comment options

@csandman
Comment options

@csandman
Comment options

@lucasrabiec
Comment options

Answer selected by lucasrabiec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants