Showing posts from July, 2019

react hooks: closer to a reactive library

react hooks: closer to a reactive library With the introduction of react hooks , the library is closer to a reactive library, perhaps closer to the original intent of react. I use react hooks via my library scalajs-reaction . One of the problems with react today is that it sometimes hard to reason about, hook functions (the new component hotness instead of classes) are not pure functions. State, ref, and other types of hooks mutate state underneath in the react “fiber” sub-system. Hooks is closer to the more ideal approach. In the ideal approach, a little bit of the DOM is updated when the data dependencies that create that part of the DOM change. For example, if a text object changes, then a div or p should change in the DOM. You can do this with hooks, but it looks like (taken from the react hooks website): function Example ( { suffix } ) { const [ count , setCount ] = useState ( 0 ) ; return ( < div > < p > You clicked {