I am using the following example, which i took from here:

CodePudding user response:
This seems to be a compatibility issue with React 18. You can use the insiders build to make it work.
Uninstall the Headless UI package in your project and instead of npm install @headlessui/react do npm install @headlessui/react@insiders .
Or downgrade to React 17, or wait for it to get fixed.
https://github.com/tailwindlabs/headlessui#installing-the-insiders-version
