3 ms·
The React style forces a lot more object creation and copying then you're probably imagining. If you want to update an array, you generally have to make a new a
by nitwit005 4y ago
The React style forces a lot more object creation and copying then you're probably imagining. If you want to update an array, you generally have to make a new array, and copy over all the data except for your mutation: https://react.dev/learn/updating-arrays-in-state https://react.dev/learn/updating-arrays-in-state
If you, for example, hold your voxel level data in a big array, that means copying that data every time the level is modified.
- shmde 4y ago"The React style forces a lot more object creation and copying then you're probably imagining." Its not react style its literally the core of how react works(immutablity). To rerender a component you need the new state to point towards a new reference to an object/array (hence the copying data to a new array) because JS compares objects/arrays through reference and not value. Not exactly react's fault but how JS works.
- nitwit005 4y agoI said "react style" because they are not using React in a conventional way: https://github.com/kevzettler/react-regl https://github.com/kevzettler/react-regl