Error when enabling react-scan in webpack production mode
Hi,
I'm trying to enable react-scan on a staging server using a production build. However, when I enable react-scan, I get the following error:
Do not use scan directly in a Server Component module. It should only be used in a Client Component.
As far as I can tell, the only difference between getting the error and being able to use scan is the switch between using webpack's "development" and "production" modes.
I'm using webpack 5.72.0 and react 17.
Any help would be appreciated! Thank you!
I am seeing this as well in my nextjs app when running the production build.
This error does not show up for npm run dev, but it does show up for npm run build && npm run start.
Able to reproduce, working on removing the error when it shouldn't show
This error can be ignored in the mean time
Thanks for the reply! But actually, the error is blocking and makes it impossible to activate scan. It looks as though the shim is not being replaced properly when building in production mode.
Are there any news? I'm using Next.js 14.2, and I'm also facing this issue although my component is marked as 'use client'.
Are there any news? I'm using Next.js 14.2, and I'm also facing this issue although my component is marked as
'use client'.
Planning on getting a fix out soon (~next release). Haven't had much time to work on the project lately, but have some free time upcoming
This error is no longer present in [email protected]
If you want to run react-scan in production you can use the following:
import {scan} from 'react-scan/all-environments'
scan() // <- works in production and dev