Incorrect production enviroment detection
React Scan would not run in many conditions where multiple react root exists, such as Next.js dev environment.
https://github.com/aidenybai/react-scan/blob/0fae9f3ab1ff25e98a4307bf826a4dd2c50a168a/packages/scan/src/core/index.ts#L537
export const getIsProduction = () => {
if (isProduction !== null) {
return isProduction;
}
rdtHook ??= getRDTHook();
for (const renderer of rdtHook.renderers.values()) {
const buildType = detectReactBuildType(renderer);
if (buildType === 'production') {
isProduction = true;
}
}
return isProduction;
};
For example, in Next.js dev environment, the next-devtools overlay uses production build of react and has separate root.
getIsProduction helper wrongly sets isProduction to true, so react-scan is not enabled.
For temporary workaround, you can set dangerouslyForceRunInProduction option to true and use other methods to decide whether to run scan.
Thanks for the issue, will get this fixed!
Same issue
you may use a trick be like
if (IS_DEV) {
scan({
enabled: true,
dangerouslyForceRunInProduction: true,
})
}