Closed rchanou closed 5 years ago
This would be great... The syntax is very verbose, and the majority of components in an app are generally functional / stateless components.
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.
@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.
"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.
In most cases, I prefer encapsulated component's state if that's what you're asking.
This is now available in ReasonReact 0.7.0 - see https://reasonml.github.io/reason-react/docs/en/components
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. 🙂