Skip to content

Create Render Event Handling Help #85

Answered by bryanmylee
rgfx asked this question in Q&A
Discussion options

You must be logged in to vote

You can use a dispatcher with createRender! It will handle all events that the component dispatches, including native and createEventDispatcher events.

The issue with your example is that your EditButton.svelte isn't dispatching any events.

You can fix it by using Svelte's event forwarding:

<!-- EditButton.svelte -->
<script>
  export let id;
</script>

<button on:click>
  {id}
</button>

or using an event dispatcher:

<!-- EditButton.svelte -->
<script>
  import {createEventDispatcher} from 'svelte';

  const dispatch = createEventDispatcher();
  export let id;
</script>

<button on:click={() => dispatch('click')}>
  {id}
</button>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rgfx
Comment options

Answer selected by rgfx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants