I'm building a Word Dojo clone in React/Flux. The game is essentially Boggle - you make words by clicking on adjacent letters in a grid:
My React components with their source:
All of the source code can be viewed here.
How it's working right now:
There's a GameStore that holds a two-dimensional array of javascript objects. the objects have a 'letter' string value and an 'active' boolean value. When the user clicks a letter, that dispatches to the GameStore, which updates that two-dimentional array and emits a Change event.
The GameBoard component listens for that change event, and then re-renders 10 TileColumns, which in turn render 10 Tiles each. GameBoard has the store's data as part of its state, and tiles have their own letter/active status as props.
The problem is that changing 1 letter causes all 100 tiles to be re-rendered.
shouldComponentUpdate
I tried using shouldComponentUpdate on the Tile to specify that it should only update if its 'active' value has changed, but the problem is that both this.props.active and nextProps.active are always the same value: either they're both false, or both true.
Deferring responsibility to the children
The other idea I had was to have each Tile responsible for its own updating, by registering change listeners on the tiles directly. I got a warning that I was exceeding the number of listeners, and it does seem like 100 change listeners all firing on every letter update would be less efficient. Although that's all just Javascript, so we'd be avoiding some DOM manipulation...
Performance
I fired up the Profiler and right now, with the parent doing all of the state management, it's taking 40ms to re-render the whole board on letter click. Which isn't bad, but when the game gets more complex, I'm worried it'll become a noticeable delay.
Help needed
Specifically I'm looking for advice on best practices in this situation (when you have nested, iterated components), and if shouldComponentUpdate is the solution but I'm just using it wrong.
Thanks!