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

Remove internal suspense boundary #298

Open
alexandernanberg opened this issue Oct 31, 2021 · 4 comments
Open

Remove internal suspense boundary #298

alexandernanberg opened this issue Oct 31, 2021 · 4 comments

Comments

@alexandernanberg
Copy link
Contributor

I can't see a good reason why there is a suspense boundary inside the library, this should ideally be handled by consumers for more granular control. E.g. consumer might not want to render null.

function Physics(props: ProviderProps) {
return (
<Suspense fallback={null}>
<Provider {...props} />
</Suspense>
)
}

This would unfortunately be a breaking change, but in the long run I think it's a good one.

@bjornstar
Copy link
Member

Would it be useful to provide a fallback property to the props?

@alexandernanberg
Copy link
Contributor Author

alexandernanberg commented Nov 4, 2021

Not really for my use-case tbh, because it doesn't enable composability in the same way.

E.g. imagine this scenario

<Canvas>
	<Suspense fallback={<Loading />}>
		<ComponentThatLoadsAsset />
		<Physics>
			<ComponentThatLoadsAsset />
		</Physics>
	</Suspense>
</Canvas>

@drcmda
Copy link
Member

drcmda commented Nov 4, 2021

i agree, it would be more flexible if it's in userland. it is a breaking change though, would require a new major.

btw @alexandernanberg your example wouldn't work, you can't have raw text or dom nodes within the canvas, but this would be ok:

<Suspense fallback="Loading...">
  <Canvas>	
    <ComponentThatLoadsAsset />
    <Physics>
      <ComponentThatLoadsAsset />
    </Physics>
  </Canvas>
</Suspense>

@alexandernanberg
Copy link
Contributor Author

@drcmda Oh right, good point, was just quickly typing out pseudo-code 😄

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

3 participants