5 ms·
The benchmarks are very interesting. I wonder what React's performance would look like when using immutable data structures, such as those by Immutable.js (anot
by graffitici 11y ago
The benchmarks are very interesting. I wonder what React's performance would look like when using immutable data structures, such as those by Immutable.js (another FB project). It seems to me that you would again get the benefit of immutable data in the diffing algorithm; namely that the one can check if any data has changed just be checking shallow equality.
I really admire Elm for being a trailblazer for pushing techniques such as reactive programming, but it seems to be that it's unlikely to be very mainstream. This is why I'd love to see the performance benefits using more mainstream solutions with JS.
- mbrock 11y agoSemi-tangential note: React comes with the helpful `React.addons.update`, which implements "immutable data structures" in an extremely simple way. I'm working on a medium-sized React application where all application state changes go through this function—there's one big state object with all substate, and we don't do any mutation inside of it. We haven't needed to benchmark anything yet, nor do we have any extreme performance requirements. Since all our state updates work like this, we can use `PureRenderMixin` on all components, which gives us the kind of shallow equality behavior you describe.
- graffitici 11y agoI see, so there's no need to even use an external library. It doesn't look like they are using the PureRenderMixin for the benchmarks. Would be curious to see how they compare then..
- mbrock 11y agoThey do implement `shouldComponentUpdate` on the todo items in a way that should give about the same performance boost. (All the pure render mixin does is implement that method using shallow equality.)