Allow components to return Promises (maybe using lazy
)
#896
titoBouzout
started this conversation in
Ideas
Replies: 2 comments 8 replies
-
I'm personally against this. If we want this, this may negatively impact |
Beta Was this translation helpful? Give feedback.
0 replies
-
Why not have a Promise trigger a components' state instead of abusing suspense here? const EventuallyHelloWorld = () => {
const [message, setMessage] = createSignal<JSX.Element>(null);
new Promise((resolve) => {
setTimeout(() => resolve(<div>Hello World</div>), 2000);
}).then(setMessage);
return message
}; Using lazy would only make sense if you need Suspense in order to manage Fallbacks. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Came across a component on which I need to run a
Promise
so I was wondering, if it would be possible to return Promises from the component.This seems to be possible already using
Suspense
https://www.solidjs.com/tutorial/async_suspense?solved
The problem of this is that when you are not importing a component, inlining it requires a lot of boilerplate: (courtesy of @mdynnl )
https://playground.solidjs.com/?hash=101461053&version=1.3.9
Ideally, one would, may like to do the following :
A suggestion from @mdynnl is to use
lazy
, although I dot not have the understanding necessary to know about the implicationshttps://discord.com/channels/722131463138705510/722349143024205824/955913065809989642
Thoughts? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions