HashtagOctothorp
HashtagOctothorp
SSolidJS
Created by HashtagOctothorp on 1/19/2024 in #support
How to refetch a "use server" function / RPC?
I've created a server function that I can confirm works as expected, now I'm trying to figure out how to "correctly" re-run this function on a timed interval. Using the documentation (https://start.solidjs.com/core-concepts/data-loading), it first mentions createResource() for requests, which makes sense since it comes with a mutate and refetch function. Then it goes on to give a "Data loading always on the server" example, now moving to createAsync and cache (both /router imports), but from my attempts to use those examples, they work for initial page load but do not appear to contain mechanisms for re-running the server function and updating the UI accordingly. Additionally, the example listed above doesn't seem to actually run anything async (there's no await in that async server function), so I'm wondering if maybe the example is still missing something (like when is the route object used?! Is it a magic object / used somehow when exported from a page? Not listed in API Routes tab). Am I missing something? Thanks! (Code examples in thread)
104 replies
SSolidJS
Created by HashtagOctothorp on 1/19/2024 in #support
Conditional Component Type rendering?
I am trying to work on a component where depending on a variable I need to wrap it with either an <a> tag or a <div>. The only conditional flow related documentation uses the <Show> component, but I'm trying to do something more akin to
// pseudo JSX
<props.url ? a : div>
<div>the same other elements</div>
<Etc />
</a or div>
// pseudo JSX
<props.url ? a : div>
<div>the same other elements</div>
<Etc />
</a or div>
I'm pretty sure something like the following would work, but how do I do this with basic HTML elements?
const ConditionalComponent = props.url ? componentA : componentB
...
<ConditionalComponent>
<div>otherstuff</div>
</ConditionalComponent>
const ConditionalComponent = props.url ? componentA : componentB
...
<ConditionalComponent>
<div>otherstuff</div>
</ConditionalComponent>
thanks!
3 replies
SSolidJS
Created by HashtagOctothorp on 2/20/2023 in #support
Typescript type for generic html props passthrough?
Looking to create a generic wrapper component that can take arbitrary HTML props (class, etc) without manually defining each prop. The Component type is too generic in this case. Is there a simple way to union the Component type with the generic HTML types? React has the React.HTMLProps option. Is there recommended approach?
8 replies