danoc/react-use-clipboard

Can't import the named export 'useState' from non EcmaScript module (only default export is available)

PJijin opened this issue · 2 comments

Got this error when I use this as mentioned in the example.

./node_modules/react-use-clipboard/dist/react-use-clipboard.mjs
Can't import the named export 'useState' from non EcmaScript module (only default export is available)

Code

import useClipboard from "react-use-clipboard";


export default function Home() {
    const [query, setQuery] = useState('');
    const [isCopied, setCopied] = useClipboard("Text to copy");
}

Version

"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-use-clipboard": "0.1.2",

Same

danoc commented

Hi @PJijin and @pr1ntr — I think I've fixed this in v0.1.3. I wasn't able to reproduce in CodeSandbox, but some searching seems to indicate that the issue is related to the .mjs file extension: apollographql/react-apollo#1737

Feel free to re-open if it is not working.