Skip to content

Changing the file for the Environment component causes white screen #1328

Answered by drcmda
calbch asked this question in Q&A
Discussion options

You must be logged in to vote

every async component is based on suspense. when a component inside a suspense bound suspends then everything in that bound will be unmounted and remounted once the async thing has completed.

in other words, it's up to you to wrap stuff in additional suspense bounds to prevent things from getting affected.

<Canvas>
  <Something />
  <SomethingElse />
  <Suspense fallback={null}>
    <Environment files={envMap}>
  </Suspense>

now the env won't affect the rest of the scene.

you can hang on to the current thing without going into a fallback with the useTransition hook. https://beta.reactjs.org/reference/react/useTransition

you can also preload stuff in the background so that it becomes immed…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@calbch
Comment options

Answer selected by calbch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working
2 participants
Converted from issue

This discussion was converted from issue #1327 on March 02, 2023 09:52.