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

Doesn't work with Next.js #58

Closed
karanshah229 opened this issue Apr 5, 2023 · 2 comments
Closed

Doesn't work with Next.js #58

karanshah229 opened this issue Apr 5, 2023 · 2 comments

Comments

@karanshah229
Copy link

Stack:

"next": "^13.1.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-redux": "^7.2.0"

@karanshah229 karanshah229 changed the title Nextjs - Doesn't work with Next.js Doesn't work with Next.js Apr 5, 2023
@dan-p-p
Copy link

dan-p-p commented May 23, 2023

Working with next-js (same stack as yours, one minor version up on Next and React.

I managed to get the Babel integration working also. Initially I followed the steps explained here: and that worked.

  1. Install with npm/yarn and --dev or --no-save
  2. import { useWhatChanged } from '@simbathesailor/use-what-changed';
  3. usage:

// (guarantee useEffect deps are in sync with useWhatChanged)
let deps = [a, b, c, d]

useWhatChanged(deps, 'a, b, c, d');
useEffect(() => {
// your effect
}, deps);

As mentioned, following the instructions here for the Babel installation in Next.js worked - note, you'll need to restart Node to get the Babel config to load.

@timreach
Copy link

timreach commented Jul 18, 2023

That code you've provided as an example here isn't using the babel plugin though so is a little confusing. That would work without the plugin as it's using the useWhatChanged direct call. The babel plugin allows you to use // uwc-dubug above your hooks to automatically debug.

I can confirm that I have it working using the config provided in the linked repo though.

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