4 ms·
Consider the React function: function Hello() { return <div>Hello</div> } The div object is where the visual representation is handled. React
by randomdata 2y ago
Consider the React function:
function Hello() {
return <div>Hello</div>
}
The div object is where the visual representation is handled. React in this case is only concerned with passing data to it, which is explicitly the model's concern under MVC. Although I suggest that event handling is really why people choose React, and that is the controller's concern according to MVC.
Again, React isn't designed for the MVC model, so we have to really stretch ourselves to find any kind of similarities. But if React was only the V to the greatest extent that we can pervert the meaning of V, what value does it add?
- breadwinner 2y ago> what value does it add? Efficient updates.
- randomdata 2y agoUpdates are the job of the model under MVC. Are you trying to imply that React is meant to serve the M, or are you trying to avoid the question?
- BalinKing 2y agoI think they meant "efficient updates [of the DOM]".
- lcnPylGDnU4H9OF 2y agoI think what OP and others are talking about when they refer to React as being the view part of model-view-controller is that a server might render a React component in the view layer after the controller has decided what data to collect and which layout to use. I think something other people sometimes talk about are single-page applications, in which case it's not a single component being rendered but an entire application. At that point MVC was simply disregarded by the developers because React is really just trying to be the V in MVC.
- randomdata 2y agoThat would be what is known as the template layer, not the view layer. If we're just randomly making up definitions for MVC, then sure, anything goes. But as nobody has provided the the arbitrary definition they just came up with off the top of their head, surely we're sticking with the standard Smalltalk usage?