Replies: 1 comment
-
const [selectedOption,setSelectedOption]=useState(selectedOptions[0]); The function (value:Type)=>void So you have to define the function as per the context Solution`TypeScript`:
onChange={(value:Type) => {
setSelectedOption(value);
// other functionality
}}
`JavaScript`:
onChange={(value) => {
setSelectedOption(value);
// other functionality
}} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Background: Passing React State Setter to onChange automatically sets the selected value to state.
What I need is additional functionality when
<MyListbox/>
changes besides just setting state, therefore I take anonChange
function.onChange
being taken in as a prop, how to get selectedOption value outside of<MyListbox/>
component?Beta Was this translation helpful? Give feedback.
All reactions