The library for web and native user interfaces.
Mirrored from https://github.com/247TaxiDriver/QOS-React.git
Synced Nov 13, 20:45 UTC
Sprout support for rendering multiple times w different props
RFC. This is a quick sketch of adding support to Sprout to render the same component instance multiple times with different props. This doesn't test memoization (though it forms a basis for testing it, more below), but does allow us to test that the code properly reacts to inputs and doesn't get "stuck" always returning the same output even when inputs change. Possible extensions: - Support calling non-component functions multiple times - Test memoization by having the `toJSON()` helper track objects it has encountered before, assign each object a unique id, and then emit subsequent references to the same value as the id instead of the printed form of the object. For example if we call a memoized function with the same input twice in a row, today we might get output like: ``` [{a: 1}], [{a: 1}], ``` Which doesn't tell us if the object is equal. Instead we could emit output like: ``` [{a: 1}] #0, #0, ``` Which allows verifying that memoization actually happened. Or we could automate this and just assert that anything structurally equal has to be referentially equal — though there are cases with conditionals that break this.