3 ms·
You're very welcome. I do believe looking at reasonml and reasonreact is a good way to gain insight into reactjs. It's on my (so very long) to-do-list. Ed: as
by e12e 7y ago
You're very welcome. I do believe looking at reasonml and reasonreact is a good way to gain insight into reactjs. It's on my (so very long) to-do-list.
Ed: as an example, I found this (oldish) post on hooks in reasonreact:
https://dev.to/iwilsonq/reasonml-with-react-hooks-tutorial-building-a-pomodoro-timer-57h0 https://dev.to/iwilsonq/reasonml-with-react-hooks-tutorial-b...
Compare as you will with a comparable one for reactjs:
https://upmostly.com/tutorials/build-a-react-timer-component-using-hooks https://upmostly.com/tutorials/build-a-react-timer-component...
Note - I would advice looking at the reasonreact documentation for up to date tutorials and guides... It's a quickly changing landscape.
Eg:
https://reasonml.github.io/reason-react/docs/en/usereducer-hook https://reasonml.github.io/reason-react/docs/en/usereducer-h...
Finally I came across this - I thought maybe a sibling comment mentioned it - but a quick search didn't turn up anything - but imo it's a pretty strong argument for hooks (in js react) :
https://tylermcginnis.com/why-react-hooks/ https://tylermcginnis.com/why-react-hooks/
- lioeters 7y agoNice resources! I've bookmarked them for later study. That last one I like, especially where the author recommends to "forget everything about lifecycle methods" and think of hooks in the context of synchronization. It makes sense, as a declarative way to describe state and state transitions. The aspect that's unsettling is that they're not idempotent pure functions, but rather deeply tied in with how React works internally. They can't be used outside of React, and require the programmer to understand the magic that makes them stateful. The common issues that beginner users of hooks encounter, like the "captured scope" of variables, or that hooks must be run in the same order every time, never conditionally - I suppose these are some reasons that make me (and other hook skeptics) react to them as "code smell". If someone had designed a library totally unrelated to React this way, I wouldn't want to use it. Looking at ReasonML, it's quite elegant and intuitive how React Hooks fit in. In fact, the code examples look very similar to how I structure my React projects, with state and actions (instead of a reducer or Redux, they use immer for immutable state changes). I'm staying open-minded about hooks, and I think the more I learn of its roots, the more I'll come around to accepting them as part of idiomatic React.