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

Need to import react-scan into next.js as an npm package #152

Open
Traveller23 opened this issue Dec 19, 2024 · 4 comments
Open

Need to import react-scan into next.js as an npm package #152

Traveller23 opened this issue Dec 19, 2024 · 4 comments
Assignees

Comments

@Traveller23
Copy link

Currently, I can load it via URL and it works fine, but not via npm package.
The best I can do is get the hover bar to appear, but there is no animation that prompts for a re-render after the component is re-rendered.

Related issue: #82

@aidenybai aidenybai self-assigned this Dec 22, 2024
@pivanov
Copy link
Collaborator

pivanov commented Dec 25, 2024

Check this one nextjs-react-scan
Hope will help you :)

@Traveller23
Copy link
Author

Traveller23 commented Dec 26, 2024

Check this one nextjs-react-scan Hope will help you :)

I did exactly what you do, but I still only see the hover bar, and can't notice any re-rendering events.

This is my console log:
image

Environment: next.js 14.2.21, app router.

By the way, I also import React in my layout.tsx, but it's a server-side page, so I can't use react-scan.

@gruckion
Copy link

gruckion commented Dec 31, 2024

Check this one nextjs-react-scan Hope will help you :)

Can you get this added to the front page readme.

Or better yet maybe have a;

import { ReactScan } from "react-scan";

So we can just import and use;

"use client";

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

type Options = Parameters<typeof scan>[0];

export function ReactScan({ options }: { options: Options }) {
  useEffect(() => {
    scan({
      ...options,
      enabled: true,
      log: true
    });
  }, [options]);

  return null;
}

Also the Options interface is not exported so we can't access the type.

@AlexBThomsen
Copy link

image

Same for me. I do see the following on localhost but nothing about re-renders or anything insightful.

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

5 participants