Skip to content

Commit

Permalink
$ removal
Browse files Browse the repository at this point in the history
  • Loading branch information
leoelz authored Dec 7, 2023
1 parent e5ea7c2 commit 2b25d7b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/guide/components/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,14 @@ export default {

You may also declare and pass `events` as `props`, by prefixing the capitalized event name with `on`.

Using `$props.onEvent` has a different behaviour than using `$emit('event')`, as `$props.onEvent` gets the callback function declared as a listener in the parent (either `@event` or `:onEvent`).
Using `props.onEvent` has a different behaviour than using `emit('event')`, as `props.onEvent` gets the callback function declared as a listener in the parent (either `@event` or `:onEvent`).

:::warning
If both `:onEvent` and `@event` are passed `$props.onEvent` might be an array of `functions` instead of `function`, this behavior is not stable and might change in the future.
If both `:onEvent` and `@event` are passed `props.onEvent` might be an array of `functions` instead of `function`, this behavior is not stable and might change in the future.

If no handler is defined, attempting to use `$props.onEvent()` as an emitter will result in a console error.
If no handler is defined, attempting to use `props.onEvent()` as an emitter will result in a console error.

When passing an event handler as a prop and kebab-case is used (ie: `:on-event`), the handler won't be interpreted when using the `$emit('event')` emitter.
When passing an event handler as a prop and kebab-case is used (ie: `:on-event`), the handler won't be interpreted when using the `emit('event')` emitter.
:::

Because of this, it is recommended to use `$emit('event')` instead of `$props.onEvent` when emitting events and declare event listener using event directives as `@event` instead of `:onEvent`.
Because of this, it is recommended to use `emit('event')` instead of `props.onEvent` when emitting events and declare event listener using event directives as `@event` instead of `:onEvent`.

0 comments on commit 2b25d7b

Please sign in to comment.