Dealing with vjs in a Next.js app with reactStrictMode #8599
stephenlindauer
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For context, Next.js has a "feature" where when reactStrictMode is enabled (which it is by default), it will run useEffect hooks twice.
Because of this, my useEffect cleanup function is destroying the player as soon as the page loads (on the second render). I've verified the player is setup and working great if I disable strict mode, but the rest of the dev team has it enabled, so I'd like to be able to fix this properly. What's the proper way to re-create the player after it gets destroyed, or how are other people in Next.js handling cleanup?
Code sample:
When this runs, the console shows:
But the player doesn't show up (just empty space), so I'm guessing I'm creating the player wrong, or need to do something different for re-creating it.
Any help is greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions