Martnart
Explore posts from serversBest way of passing props from Provider to Context
If you do not intend to alter the data in any way, I guess your way is absolutely fine, that way you don't have to duplicate the data.
Depending on your specific setup, you could also move the resource directly into the provider to begin with so you don't have to worry about the props.
6 replies
Best way of passing props from Provider to Context
This sounds like a store scenario to me.
Only problem here is timing in terms of initial data.
You could wrap the provider with a
Show when={markets()}
to make sure initial data has loaded, or you can add an effect that updates the store when props.markets
changes
Is that kind of what you are looking for?
With a store you retain reactivity wherever you use it.6 replies
Navigate user in login/logout functions
Usually Contexts are part of a Provider component. If you did that, I think it would have the behavior that you want. Also a bit suspect that you have a session signal at the root level of the page. If you'd have it inside a Provider it'd be scoped as would be expected.
5 replies
Variable initialized in `onMount` becomes `undefined`
I meant that an effect returned from
createEffect
will execute before onMount
Edit: Need to add that I am talking about an SSR context. Might well be not relevant for this particular use-case.7 replies
Is it possible to pass paramters a function wrapped by a createEffect/createMemo?
If the parameters themselves are reactive you should just declare them as signals and have the memo listen to them:
If they are static you could do something like this:
2 replies
Any pattern to avoid getting ts angry when using route data fields?
https://playground.solidjs.com/anonymous/b542915b-456e-4324-96dc-3106a9cc2f87
Edit: pasted wrong link, sorry
20 replies
Any pattern to avoid getting ts angry when using route data fields?
You could rewrite your
when
to actually return the output such as when={clans()?.invitations.length > 0 && clans()}
and then work with the callback but it seems a bit cumbersome.20 replies
Any pattern to avoid getting ts angry when using route data fields?
Yes but it's another way of making TS think something. You are fine in this case to do a non-null-assertion. It is kind of encouraged to a certain degree since the latest
<Show>
update. It's just a bit hard to get the typing right. But whatever is guarded by a show, will be defined, basically.20 replies