react-scan icon indicating copy to clipboard operation
react-scan copied to clipboard

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

Open henryzhang03 opened this issue 11 months ago • 8 comments

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.

henryzhang03 avatar Dec 23 '24 20:12 henryzhang03

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.

danieldunderfelt avatar Dec 23 '24 21:12 danieldunderfelt

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

RobPruzan avatar Dec 24 '24 04:12 RobPruzan

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

Works but log is there

henryzhang03 avatar Dec 24 '24 04:12 henryzhang03

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?

lxsmnsyc avatar Dec 24 '24 06:12 lxsmnsyc

yupp doesnt work

myudak avatar Dec 24 '24 13:12 myudak

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??

myudak avatar Dec 24 '24 13:12 myudak

@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

lxsmnsyc avatar Dec 24 '24 15:12 lxsmnsyc

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?

aztack avatar Dec 27 '24 11:12 aztack

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

mattbolanos avatar Jan 01 '25 18:01 mattbolanos

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

jkronlachner avatar Jan 15 '25 07:01 jkronlachner

image

This works for me! Thanks @jkronlachner!

rodrigomoyano11 avatar Jan 15 '25 18:01 rodrigomoyano11

Also these can help too :) https://github.com/aidenybai/react-scan/tree/main/docs/installation

pivanov avatar Feb 13 '25 16:02 pivanov