Skip to content

Commit

Permalink
fix: Make Reflector HMR-proof (#292)
Browse files Browse the repository at this point in the history
Any time we wire up a useFrame, furiously null-check refs inside it as an HMR (in Next.js) will trigger an unmount but not before a final frame ticks off, crashing us.
  • Loading branch information
CharlieHess authored Feb 7, 2021
1 parent 214ee27 commit ba70694
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/core/Reflector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export function Reflector({
])

useFrame(() => {
if (!meshRef?.current) return
meshRef.current.visible = false
beforeRender()
gl.setRenderTarget(fbo1)
Expand Down

1 comment on commit ba70694

@vercel
Copy link

@vercel vercel bot commented on ba70694 Feb 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.