TS1471

TS1471: Module ‘@headlessui/react‘ cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.

Broken Code ❌

1
import { FocusTrap } from '@headlessui/react';

Fixed Code ✔️

Using a dynamic import:

1
const { FocusTrap } = await import('@headlessui/react');