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

does not display re-render when react-compiler + memo is used #229

Open
MrOxMasTer opened this issue Feb 2, 2025 · 7 comments
Open

does not display re-render when react-compiler + memo is used #229

MrOxMasTer opened this issue Feb 2, 2025 · 7 comments

Comments

@MrOxMasTer
Copy link

Does not display re-render:
https://github.com/user-attachments/assets/e8fe1054-cd5b-4ff1-9f6b-abef7f6847cc

Code:
https://codesandbox.io/p/devbox/xwdywd

@pivanov
Copy link
Collaborator

pivanov commented Feb 2, 2025

Hey did you use the script tag or? how do you use it?

@MrOxMasTer
Copy link
Author

MrOxMasTer commented Feb 9, 2025

Hey did you use the script tag or? how do you use it?

I don't remember exactly at the time of testing, but I have it now:

'use client';

import { useEffect } from 'react';
import { scan } from 'react-scan';

export const ReactScan = () => {
  useEffect(() => {
    scan({
      enabled: process.env.NODE_ENV === 'development',
      log: false,
    });
  }, []);

  return null;
};

@lxsmnsyc
Copy link
Collaborator

lxsmnsyc commented Feb 9, 2025

@MrOxMasTer Try putting the react-scan import before react and then on the file where it is used, put it the ReactScan component as your first import.

@MrOxMasTer
Copy link
Author

@MrOxMasTer Try putting the react-scan import before react and then on the file where it is used, put it the ReactScan component as your first import.

I'm using next.js (app router). How can I do this?

@MrOxMasTer
Copy link
Author

MrOxMasTer commented Feb 9, 2025

I just don't want to download the package every time before each render, so I installed the npm package. This is to the way you suggest (via script) for the next.js app router

@lxsmnsyc
Copy link
Collaborator

lxsmnsyc commented Feb 9, 2025

I'm using next.js (app router). How can I do this?

// Your ReactScan component file
- import { useEffect } from 'react';
import { scan } from 'react-scan';
+ import { useEffect } from 'react';

and when you import your ReactScan component, put it at the top of the file (if you're importing it in your root layout)

@MrOxMasTer
Copy link
Author

Kind of trying to replicate the same scenario that led to this breakdown, but now no matter how I import, everything works fine. Ok, I'll hope that it's really fixed this way (by changing the import order)

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

3 participants