#avoid re-render?
12 messages · Page 1 of 1 (latest)
Where you call the signal, is what you chose to rerender
I guess it’s not the same with props because getters, but it’s the same idea
If you want to keep children but change data then data needs to be a signal
Because in the first example you’re passing a signal
and in the second the value
But it gets it as a getter though props, so it actually controls when the signal gets called, not the parent
In the first example the battle prop ends up being a getter
You can make it to behave like the second by adding a keyed prop to Show
Show can take a callback, you get a type narrowed signal there
It will reduce type casting
But it’s the same thing
<WhenData res={rBattleState}>{c =>
<TryRenderInner battle={c()} />
}</WhenData>
function WhenData<T>(props: IWhenDataProps<T>) {
return (
<Show when={props.res().is === Res.Data}>
{props.children(() => (props.res() as ResData<T>).data)}
</Show>
);
}