Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[React Scan] Failed to load. Must import React Scan before React runs. #162

Open
henryzhang03 opened this issue Dec 23, 2024 · 11 comments
Open

Comments

@henryzhang03
Copy link

We use the script tag version. This appears "[React Scan] Failed to load. Must import React Scan before React runs." in our Next JS App Router project.

@danieldunderfelt
Copy link

danieldunderfelt commented Dec 23, 2024

Same here, running with npx react-scan@latest localhost:3000

It worked on the same site a few days ago 😩

Edit: For me it works with the script tag.

@RobPruzan
Copy link
Collaborator

@henryzhang03 is react-scan not working for you at all? Or is the log there, but it still works?

@henryzhang03
Copy link
Author

@henryzhang03 is react-scan not working for you at all? Or is the log there, but it still works?

Works but log is there

@lxsmnsyc
Copy link
Collaborator

Usually this is the cache (either the dev build or the browser) lagging behind, have you tried deleting the cache and/or performing hard refresh?

@myudak
Copy link

myudak commented Dec 24, 2024

yupp doesnt work

@myudak
Copy link

myudak commented Dec 24, 2024

Same here, running with npx react-scan@latest localhost:3000

It worked on the same site a few days ago 😩

Edit: For me it works with the script tag.

how??

@lxsmnsyc
Copy link
Collaborator

@myudak oh you probably have to use react-scan's auto mode (which is basically loading react-scan from the CDN), without marking it async

@aztack
Copy link

aztack commented Dec 27, 2024

Is Preact supported by react-scan?
I've tried

  • import scan and config manually
  • add script tab before any other scripts
  • npx react-scan localhost
    in my Preact 'hello world' project and keep getting this error.

update:
I replace Preact to React and it works fine.

Will (and when) Preact be supported?

@mattbolanos
Copy link

i am receiving this error as well by using the script in Next.js App Router

@jkronlachner
Copy link

jkronlachner commented Jan 15, 2025

for me this was fixed using a plain
<Script src="https://unpkg.com/react-scan/dist/auto.global.js" /> with the next/script in the head of my root layout.tsx.
After that change make sure to clear the cache

@rodrigomoyano11
Copy link

image

This works for me! Thanks @jkronlachner!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants