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

Cannot read properties of undefined (reading 'destroy') on live reload #227

Closed
IanBoyte opened this issue Oct 24, 2023 · 14 comments
Closed

Comments

@IanBoyte
Copy link

Running locally, whenever a live reload occurs, ex. after updating a css module file, the following error occurs:

Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'destroy')

Call Stack

ParallaxProvider.componentWillUnmount
node_modules/react-scroll-parallax/dist/react-scroll-parallax.esm.js (412:0)

callComponentWillUnmountWithTimer
node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (19660:0)

The following is our implementation of the ParallaxProvider:

'use client';

import { ParallaxProvider, useParallaxController } from 'react-scroll-parallax';


export default function Providers({ children }) {
	return (
		<ParallaxProvider>
			<Cursor />
			{/* <FixParallaxScrollEvent /> */}
			{children}
		</ParallaxProvider>
	);
}

"next": "13.4.9", (downgraded due to issue seen here)
"react": "18.2.0",
"react-dom": "18.2.0",
"react-intersection-observer": "^9.5.2",
"react-scroll-parallax": "^3.4.2",

@joelpierre
Copy link

It's a react strict mode thing. If you turn off strict mode in dev then it works fine.

However that being said the code should be resilient to how react 18+ works so ideally the author can update the package to handle strict mode.

@raRaRa
Copy link

raRaRa commented Oct 31, 2023

This should definitely be fixed in this library, also caused an issue for me in Nextjs 14

@jscottsmith
Copy link
Owner

try v3.4.3

@raRaRa
Copy link

raRaRa commented Nov 2, 2023

I now get Error: Could not find react-scroll-parallax context value. Please ensure the component is wrapped in a

Whenever I save. Even though the wrapper is in the layout file.

I also see this error:

app-index.js:31 Warning: Cannot update a component (`HotReload`) while rendering a different component (`Parallax`). To locate the bad setState() call inside `Parallax`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render

@jscottsmith
Copy link
Owner

jscottsmith commented Nov 2, 2023

@raRaRa mind creating and sharing a minimal repo reproducing your setup? I'm unable to reproduce these hot reloading errors in my current setup - see repo here

@hatem-72
Copy link

hatem-72 commented Nov 3, 2023

I now get Error: Could not find react-scroll-parallax context value. Please ensure the component is wrapped in a

Whenever I save. Even though the wrapper is in the layout file.

I upgraded to v3.4.3 and now the context value isn't there, even though I put around my app.

Just so you know, I'm using my own container ref.

@fer112233
Copy link

I am also experiencing the issue:
Error: Could not find react-scroll-parallax context value. Please ensure the component is wrapped in a

Using Next on version 3.4.3 of this package

@jscottsmith
Copy link
Owner

If anyone can share a minimal repo that reproduces this error and clear steps to take for reproduction, that would be more helpful.

@raRaRa
Copy link

raRaRa commented Nov 7, 2023

Here's a way to reproduce this:

https://codesandbox.io/p/sandbox/silly-flower-glpydx?layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clooe8foe00093b6km4ofnuxx%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clooe8fod00033b6k3qgprd2z%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clooe8fod00063b6ki4gtyska%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clooe8fod00083b6kst3r4j6w%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clooe8fod00033b6k3qgprd2z%2522%253A%257B%2522id%2522%253A%2522clooe8fod00033b6k3qgprd2z%2522%252C%2522activeTabId%2522%253A%2522clooeghw801jw3b6ki8d7ow6b%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clooe8fod00023b6kn0i4919m%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252FREADME.md%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fapp%252Flayout.tsx%2522%252C%2522id%2522%253A%2522clooe9gxo008w3b6kr4pkbtl5%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fcomponents%252FParallaxWrapper.tsx%2522%252C%2522id%2522%253A%2522clooeaffd00e93b6ksni0h6fr%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fcomponents%252FAnimatedDiv%2520%28DELETED%29%2522%252C%2522id%2522%253A%2522clooef9nx01873b6karmei4ji%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fcomponents%252FAnimatedDiv.tsx%2522%252C%2522id%2522%253A%2522clooefln701ad3b6kcppd4u2j%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fapp%252Fpage.tsx%2522%252C%2522id%2522%253A%2522clooeghw801jw3b6ki8d7ow6b%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fapp%252Fglobals.css%2522%252C%2522id%2522%253A%2522clooeh35n01o53b6kwyxsr7jb%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%257D%252C%2522clooe8fod00083b6kst3r4j6w%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clooe8fod00073b6kj5mtlbfw%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_PORT%2522%252C%2522taskId%2522%253A%2522dev%2522%252C%2522port%2522%253A3000%252C%2522path%2522%253A%2522%252F%2522%257D%255D%252C%2522id%2522%253A%2522clooe8fod00083b6kst3r4j6w%2522%252C%2522activeTabId%2522%253A%2522clooe8fod00073b6kj5mtlbfw%2522%257D%252C%2522clooe8fod00063b6ki4gtyska%2522%253A%257B%2522id%2522%253A%2522clooe8fod00063b6ki4gtyska%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clooe8fod00043b6khu396n70%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%257D%252C%257B%2522id%2522%253A%2522clooe8fod00053b6kxteur9ds%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522install%2522%257D%255D%252C%2522activeTabId%2522%253A%2522clooe8fod00053b6kxteur9ds%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

@raRaRa
Copy link

raRaRa commented Nov 7, 2023

To reproduce, try editing page.tsx and adding <AnimatedDiv />'s or editing page.tsx in general. You should see that error come up. This also shows the issue with parallax effect just working initially, and then it stops. Maybe you can figure out what's going on, but I have a feeling that the library is not handling cases with strict mode, e.g. calling useEffects twice.

@raRaRa
Copy link

raRaRa commented Nov 19, 2023

I have a PR that should fix these issues: #234

jscottsmith added a commit that referenced this issue Nov 21, 2023
- related to strict mode issues #233 #227 and #221
- credit to @raRaRa for #234
@jscottsmith
Copy link
Owner

Please try v3.4.4 to see if this issue is resolved.

@IanBoyte
Copy link
Author

IanBoyte commented Nov 21, 2023

This issue appears to be resolved for me, running "react-scroll-parallax": "^3.4.4" and "next": "^14.0.3".

@gisbelt
Copy link

gisbelt commented Dec 7, 2023

This issue appears to be resolved for me, running "react-scroll-parallax": "^3.4.4" and "next": "^14.0.3".

Same here, resolved using: "^3.4.4" and "next": "^14.0.3".

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

7 participants