stephane-vanraes / renderless-svelte

A collection of renderless Svelte components
MIT License
277 stars 11 forks source link

Modal openModalV2() gives me a slot error #27

Closed raafirivero closed 2 years ago

raafirivero commented 2 years ago

I am trying to create several modal objects for different pieces of data. Whenever I use the openModalV2() command I get the error <ModalV2> received an unexpected slot "default".

I'm calling the command like so and want to embed a svelte component called PlayerBox. Any ideas what I'm doing wrong here?

<span class="open" on:click={() => openModalV2(player)}>{player.name}</span> <ModalV2 let:payload let:close> <div class="full"> {payload} <button class="close" on:click={close}>&times;</button> <PlayerBox player={player} /> </div> </ModalV2>

raafirivero commented 2 years ago

The way I got it to work without errors was sending the component I wanted to open and its properties as the payload and not trying to put anything between the <ModalV2> tags. In fact I used <ModalV2 /> as a self-closing tag.

<span class="open" on:click={() => openModalV2(PlayerBox, {player: player})}>

In this setup <ModalV2 /> opens a component called "PlayerBox", which needs a property called "player."