Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Functional components events #3348

Closed
miljan-aleksic opened this issue Jul 29, 2016 · 2 comments
Closed

[Feature] Functional components events #3348

miljan-aleksic opened this issue Jul 29, 2016 · 2 comments

Comments

@miljan-aleksic
Copy link

I know a functional component is stateless and instanceless reason why it can't emit an event. But in situations where the component is used to programatically evaluate which sub component to render it would make sense to be able to listen to those subcomponents events.

Eg a Field component which return a diferent root component depending on the type would not allow doing something like this.

<field
  type="Boolean"
  @change="changed">
</field>
@yyx990803
Copy link
Member

You can just pass the raw data down to the returned component:

render (h, { data, children }) {
  return h(component, data, children)
}

data includes event listeners, so the listeners will be registered on the returned component.

@miljan-aleksic
Copy link
Author

Awesome @yyx990803, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants