3 ms·
>The author does not understand React :( The author understands React quite well, it's this comment that, while also understanding React, misses the author's p
by coldtea 11y ago
>The author does not understand React :(
The author understands React quite well, it's this comment that, while also understanding React, misses the author's point by insisting on the superficial differences.
>It does actually - you update the state, then React propogates the changes for you through it's props mechanism.
That it achieves something (change propagation) it doesn't mean it's the solution to that thing. There's a reason the author used the wording "doesn't solve" (instead of "doesn't handle", "doesn't allow" etc). Flux (and it's variations) is what really solves propagation in React without it becoming a tangled mess.
>Flux is not message passing
Nobody said it is.
>React components do not redraw themselves
They do, that's the whole point. React components manage, compose and return their DOM representation structure which is the HTML analogous to "drawing". return(<b>{msg}</b>) IS drawing.
The fact that they don't have low level rendering code embedded in them is just an implementation detail (because of course the DOM already exists).
>React provides the view as a function of state. Windows is nothing like that.
Only the author doesn't mention Windows, the abstract OS, he mentions a specific implementation of its UI engine that clearly provides the view as a function of state.
Similar miscomprehensions of the article drive the other objections.
- dustingetz 11y agoI don't agree with your core thesis, "redraw" and "draw" are imperative verbs which are ubiquitus in winapi, `return <b>{msg}</b>` is not a verb but a value, this not superficial or an implementation detail, but rather a massive change in programming model to the point that IMO comparisons that overlook this difference are not useful at best and harmful at worst
- onli 11y agoWhy? Where is the practical difference for the program design between "returning html that the browser then draws" to "drawing themself" at the end of the flow? Serious question, and I'm not a Windows programmer, I might be missing something.
- dustingetz 11y agoyour question resolves to when to choose imperative vs OO v functional, and while I'm not going to try to discuss that here, they are profoundly different. Winapi is imperative, React is functional.
- coldtea 11y ago>Winapi is imperative, React is functional. That's a red herring. That would be relevant if we were discussing the imperative vs functional methodology. But what the article discusses is the similarity in the architecture of two view management systems. And even more so, the imperative changes in the Windows scheme described are encapsulated inside the views, and the overall system is more functional that you give it credit for. But, again, I think that this is beside the point.
- duncanawoods 11y agoI call forceUpdate to trigger redraws when view state is managed outside of props. Feels like an imperative redraw to me. https://facebook.github.io/react/docs/component-api.html#forceupdate https://facebook.github.io/react/docs/component-api.html#for...
- aljones 11y agoWell, yeah. That isn't the recommended way to use react.
- duncanawoods 11y agoIts pretty essential for non-trivial applications with data-structures more complex than can be handed over to React. setState is just sugar - it also calls forceUpdate.
- bmm6o 11y agoThere is no practical difference. You could argue that manipulating the DOM is the closest analogy to Draw(), but trying to make a distinction between that and generating HTML (that is going to be used to update the DOM) seems like splitting hairs.
- coldtea 11y agoThat's because HTML has an abstract declarative way to define the layout/drawing whereas Windows did not. But that's not especially important when it comes to React in general. The important is that the "how to draw myself" (in a high level) never leaves the view, not whether the "drawing instuctions" happen inside the app (as low level draw commands) or outside (by a mechanism that handles composable values representing markup). In both cases the view is a black box -- in that nobody else determines it's layout/style/contents. Whether somebody else or the view itself draws them might reflect a functional vs more imperative style, but it's not the key benefit of react. In fact there are React implementations like React-Canvas that don't use the DOM/diffing mechanism at all -- they just invalidate the whole top level "viewport".