Skip to content

v0.2.1

Choose a tag to compare

@thomashoneyman thomashoneyman released this 04 May 04:14
cfa94be

This release improves the performance of the Hooks library, both internally and by introducing a new memoComponent function.

Improvements:

Add memoComponent to control evaluation on input changes (#25)

When a Halogen component re-renders it sends input again to any of its child components. When a Hook component receives new input it will store that input and re-evaluate all Hooks. This can be a performance issue if a Hook function (especially an expensive one) is run unnecessarily each time the parent component renders.

This PR introduces memoComponent, a version of the component function which allows Hook components to ignore new input if it is unchanged from previous input.

Only re-evaluate Hooks after effects run if the effects modified state (#28)

Hooks were previously always re-evaluated if effects were run after the last evaluation, because it was possible that the effects modified something that could have triggered a useTickEffect's memos. However, even when the effects didn't modify state we'd still re-run Hooks. This performance optimization tracks whether the state was modified after a particular effects run and only re-evaluates Hooks if the state was actually modified.