4 ms·
> Today we know 2-way data binding is gimmicky and makes programs hard to debug. This is the reason React uses unidirectional data flow. It makes sense for sim
by loopdeloop 6y ago
> Today we know 2-way data binding is gimmicky and makes programs hard to debug. This is the reason React uses unidirectional data flow.
It makes sense for simple apps that are mainly rendering and outputting information/data.
Writing a React that handles even simple forms is however a trip back to the early days of web, where you gotta handle your own DOM events. I'm unclear when repeating the same DOM handlers all over the place became "easier to debug"
- a-priori 6y agoThat’s because React isn’t a form library, it’s a rendering library. People have built form libraries on top of it. Here’s one I’ve used and contributed to that builds two-way binding for form state in React: https://github.com/Shopify/quilt/blob/master/packages/react-form/README.md https://github.com/Shopify/quilt/blob/master/packages/react-...
- earthboundkid 6y agoOkay, but if React isn't going to handle forms for me, why am I wasting 100KB on it?
- a-priori 6y agoIf you're going to use a "if React isn't going to handle X for me, why am I wasting 100KB on it?" argument, then it wouldn't be 100KB for very long, now would it?
- earthboundkid 6y agoVue is smaller than React and does not need a form library.
- seumars 6y agoClassic webdev reply. Hey how should I properly work with data binding and forms in react? npm install react-proper-use-of-binding-and-forms-duhhh!
- arodyginc 6y agoThere are libs that make it trivial, one is Formik.
- JamesBarney 6y agoIt kinda feels like you're trading hard to debug data binding bugs, for hard to debug formik bugs.