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

AccumulatedShadows NPE protection #1701

Merged
merged 5 commits into from
Dec 18, 2023
Merged

AccumulatedShadows NPE protection #1701

merged 5 commits into from
Dec 18, 2023

Conversation

supertick
Copy link
Contributor

Why

When component is unmounted it throws.
The way its currently written

    React.useLayoutEffect(() => {
      const group = gLights.current
      if (parent) parent.lights.set(group.uuid, api)
      return () => void parent.lights.delete(group.uuid)
    }, [parent, api])

The check for valid parent is done for the lights.set, but there is no check on the

      return () => void parent.lights.delete(group.uuid)

so if parent is null this ^ line throws

What

prevents AccumulatedShadows from throwing when parent is null

Copy link

vercel bot commented Nov 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
drei ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2023 3:50pm

Copy link

codesandbox-ci bot commented Nov 3, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2404ee2:

Sandbox Source
vigorous-lake-mz6p65 Configuration
Ground reflections and video textures Configuration
arc-x-pmndrs-colors Configuration

@drcmda
Copy link
Member

drcmda commented Nov 15, 2023

hi @supertick, thanks! could you do this instead?

      if (parent) parent?.lights.set(group.uuid, api)
      return () => void parent?.lights.delete(group.uuid)

and w/o semicolons please due to the prettier config we use.

@supertick
Copy link
Contributor Author

Sure, updated.

  • removed the first parent? because its already tested with if (parent)
  • improved formatting 👍

@drcmda drcmda merged commit 8da6b24 into pmndrs:master Dec 18, 2023
1 check passed
Copy link

🎉 This PR is included in version 9.92.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants