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

Stateless components cannot be arrow functions #122

Closed
LinusU opened this issue Apr 12, 2016 · 8 comments
Closed

Stateless components cannot be arrow functions #122

LinusU opened this issue Apr 12, 2016 · 8 comments

Comments

@LinusU
Copy link

LinusU commented Apr 12, 2016

screen shot 2016-04-12 at 11 00 33

A bug in isFunctionalComponent is causing an error to be thrown when passing an arrow function as a stateless component. This is because arrow functions doesn't have a prototype, which is used in this function.

Compare these two identity functions:

screen shot 2016-04-12 at 11 02 39

This is the very simple app that I'm using together with browserify:

const { h, render } = require('preact')

const App = (props) =>
  h('h1', null, 'Hello World')

render(h(App), document.body)

Note that I'm not using babel here. This works when using babel because it converts the arrow functions to normal functions.

@developit
Copy link
Member

Ah, very good catch. Should be a quick fix.

@LinusU
Copy link
Author

LinusU commented Apr 12, 2016

Thanks for the quick fix, if you could publish a patch release right away I would be so happy! 🎉

@developit
Copy link
Member

@LinusU yes sorry - meant to publish but I had to step out for a sec. Will publish in ~20 minutes. Cheers!

@developit
Copy link
Member

By the way, not sure if it helps but I've been publishing alphas here: https://gist.github.com/developit/75e724607fe33de9e63f
For larger changes I generally publish a beta dist-tag to NPM.

@LinusU
Copy link
Author

LinusU commented Apr 12, 2016

Nice! 🙌

I'm using npm so it might be a bit tedious to include the gist...

@developit
Copy link
Member

For sure, yup.

@developit
Copy link
Member

Released as 4.6.1. Thanks!

@LinusU
Copy link
Author

LinusU commented Apr 12, 2016

Thank you!

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