kaisermann / svelte-loadable

Dynamically load a svelte component
MIT License
320 stars 13 forks source link

How to handle this warning and this situation? `<Create> was created with unknown prop 'playerID'` #54

Open frederikhors opened 2 years ago

frederikhors commented 2 years ago

I'm using svelte-loadable and the below code but I'm getting the below warning and I feel this is not a good code.

Can you suggest me how to properly handle this?

The warning: <Create> was created with unknown prop 'playerID'

The code:

<script lang="ts">
    import Loadable from "svelte-loadable";

  export let loader: string;
  // other code
</script>

<Loadable
  loader={loader === "player"
    ? () => import("$lib/../routes/players/create.svelte")
    : () => import("$lib/../routes/teams/create.svelte")
    // others here...
  }
  let:component
>
  <svelte:component
    this={component}
    {formName}
    on:SOMETHING={handleSOMETHING}
    {/* other props here */}
    playerID={loader === "player" ? playerID : undefined}
  />
</Loadable>

Is there a way I can avoid the playerID prop based on which component I'm loading?