question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React hook fails to compile

See original GitHub issue

In a CRA running React 17 attempting to use the react hook import { useAutoAnimate } from '@formkit/auto-animate/react' results in the following error:

Failed to compile.

./node_modules/@formkit/auto-animate/react/index.mjs
Can't import the named export 'useEffect' from non EcmaScript module (only default export is available)

Not using the hook, and just using the autoAnimate function in a useEffect does however work

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ethansnow2012commented, Jul 30, 2022

My Quick Fix: Instead of importing from “”@formkit\auto-animate\react", direct copy and paste it into your own codebase.

0reactions
DamienGilbrincommented, Sep 18, 2022

Hello,

I use on webpack this configuration and it’s works !

    config.module.rules.push({
      test: /\.mjs$/,
      include: /node_modules/,
      type: "javascript/auto",
    });

😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to compile react hooks() - Stack Overflow
The rules of hook plugin uses naming conventions to tell what is a component, what is a hook, and what is a regular...
Read more >
Invalid Hook Call Warning - React
You are probably here because you got the following error message: Hooks can only be called inside the body of a function component....
Read more >
How to test React Hooks - LogRocket Blog
Hooks aim to solve all of these by enabling you to write reusable components with access to state, lifecycle methods, and refs. How...
Read more >
Hooks error on React library compiled with Rollup.js #14721
I still need to add React as a devDependency and now I'm getting a different error if I use the production build (a...
Read more >
FAQs | React Hook Form - Simple React forms validation
How to create an accessible input error and message? React Hook Form is based on Uncontrolled Components, which gives you the ability to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found