Closed cristovao-trevisan closed 5 years ago
I did something wrong with the PR, while adding some changes to your code to exclude all the Loadable
props, sorry 😁.
Anyway, thanks for the PR! I'll release a new version right now.
Released on v1.1.0
:tada:
Thank you
This seems to only fix the issue when a named slot is used - the example code above would not work. Here is the current implementation:
{#if state === STATES.ERROR}
<slot name="error" {error} />
{:else if state === STATES.TIMEOUT}
<slot name="timeout" />
{:else if state === STATES.LOADING}
<slot name="loading" />
{:else if state === STATES.SUCCESS}
{#if slots && slots.success}
<slot name="success" {component} props={$$props} />
{:else}
<svelte:component this={component} />
{/if}
{/if}
Should it be? :
{#if state === STATES.ERROR}
<slot name="error" {error} />
{:else if state === STATES.TIMEOUT}
<slot name="timeout" />
{:else if state === STATES.LOADING}
<slot name="loading" />
{:else if state === STATES.SUCCESS}
{#if slots && slots.success}
<slot name="success" {component} props={$$props} />
{:else}
<svelte:component this={component} props={$$props} />
{/if}
{/if}
Alternatively (or additionally) should it copy the "rest" props (defined already as componentProps
):
{#if state === STATES.ERROR}
<slot name="error" {error} />
{:else if state === STATES.TIMEOUT}
<slot name="timeout" />
{:else if state === STATES.LOADING}
<slot name="loading" />
{:else if state === STATES.SUCCESS}
{#if slots && slots.success}
<slot name="success" {component} props={$$props} {...componentProps} />
{:else}
<svelte:component this={component} props={$$props} {...componentProps} />
{/if}
{/if}
I'm happy to make a PR.
@CaptainN I don't know what was on my mind when I was merging this PR. I completely ignored the componentProps
that I wrote moments before 🤔
Thanks for your attention on this issue 👍
@kaisermann I figured it was a 2:00am or morning commute commit or something - I been there!
Thanks for an awesome package!
Hi, I'm using this package together with svelte-routing. My use case requires passing params to rendered element, like so:
Thus there is a need to pass props to the slot or component