4 ms·
Ask HN: Why No Functional Components in Flutter?
Flutter with it's pseudo-declarative approach is inspired by React (https://flutter.dev/docs/resources/architectural-overview#reactive-user-interfaces)
Why then it's still few years behind React with its verbose class based approach?
Functions are first class citizens in Dart, so what's stopping Flutter team to improve in this direction?
Would like to hear some technical aspects and implications of this matter.
- PaulHoule 5y agoFunctional components in React are fine. (A pure component that just maps props to a DOM tree) The hooks however are cancer; React going forward with those is like trying to go forward in reverse gear. Replace a straightforward OO API with something "functional" where the result depends on the sequence the functions get called in... Side effect city.
- aristofun 5y agoHow much experience did you have with hooks based react projects? In my experience this is a blessing, once you deeply understand the basic ideas. By just comparing class vs hooks based react apps I worked with.
- aristofun 5y agohttps://github.com/flutter/flutter/issues/84266 https://github.com/flutter/flutter/issues/84266
- pax_americana 5y agoHere's a pretty good explanation. https://stackoverflow.com/a/53234826 https://stackoverflow.com/a/53234826 There is a library that would allow you to declare functional components, however it relies on code generation which might discourage others from using it. Dart is planning on adding static metaprogramming though, and that might provide a way to introduce functional components to Flutter without codegen.
- aristofun 5y agothanks for sharing