3 ms·
Good question. Both Backbone and React provide a way to build UI components. React Components are way easier for: 1. Having nested DOM elements in your compone
by TheMiddleMan 5y ago
Good question. Both Backbone and React provide a way to build UI components. React Components are way easier for:
1. Having nested DOM elements in your components. Backbone really wanted you to just have one element per component, and then use jQuery to add children as needed.
2. Adding event handlers and other HTML attributes. JSX syntax means you can basically write HTML in your JS file. Backbone made you add event handlers manually.
3. Nested components. React lets the parent simply specify what children it wants and React automatically creates/reuses/destroys component instances for you. This was all manual in Backbone.
The bigger advantage though, is how the state is typically organized in React apps.
In Backbone, app state was sprinkled throughout the component hierarchy, and often you would have do event spaghetti up and down the hierarchy to update some state held by another component.
Typical React apps use a state container like Redux, the UI is "projected" from the state, and components just send changes to the state, aka "unidirectional data flow".
That said, React is not the best for games. Maintaining 60 fps can be difficult and we've done some fairly heavy optimization to try to keep it smooth.
- thunderbong 5y agoThanks a lot for the detailed reply! Have you see SvelteJs? Would that be better suited in this scenario?