Skip to content

Listbox.Option click doesn't appear to be updating to the newly selected option during testing #2150

Answered by Abbeyy
Abbeyy asked this question in Help
Discussion options

You must be logged in to vote

Can be marked as solved. Will leave response here for a paper trail.

Fortunately, it's an issue on my end and not with HeadlessUI!

For anyone else who may come across the same situation:

My issue lied with incorrect mocking of the useState hook when rendering and testing my component. The error I saw was a misleading result; the solution was to mock my component with a Wrapper and to treat said Wrapper as a parent where you define your useState hook and pass it to the child component, like so:
`
const store = mockStore({
settingsSlice: {
newRowsPerPage: 5,
},
});

const Wrapper = () => {
  const [rows, setRows] = useState<number>(5);

  return (
    <RowsPicker
      rowsPerPage={rows}
   …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Abbeyy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant