reasonml / reason-react

Reason bindings for ReactJS
https://reasonml.github.io/reason-react/
MIT License
3.25k stars 349 forks source link

Add support for functional components #61

Closed rchanou closed 5 years ago

rchanou commented 7 years ago

Support for function components is on the roadmap, according to the docs, but I didn't find any existing issue I could track, so I'm making one now. 🙂

cullophid commented 7 years ago

This would be great... The syntax is very verbose, and the majority of components in an app are generally functional / stateless components.

alex35mil commented 6 years ago

RR has statelessComponent. Same shape w/ reducerComponent greatly simplifies adding state in case it's needed. Snippet simplifies scaffolding of component's shape.

I really like it in RR (please don't change it). JS's functions vs classes thing is terribly annoying and counterproductive.

cullophid commented 6 years ago

@alexfedoseev It depends on how you structure your application. If you are using a lot of stateful components the current setup is fine, but if you are using an elm style architecture you only ever need stateless components.

cullophid commented 6 years ago

"adding state in case its needed" made me cringe a bit. Immutability is one of the core features of the language exactly because its important that you are careful and deliberate about how where you have state.

alex35mil commented 6 years ago

In most cases, I prefer encapsulated component's state if that's what you're asking.

phated commented 5 years ago

This is now available in ReasonReact 0.7.0 - see https://reasonml.github.io/reason-react/docs/en/components