ianstormtaylor / react-values

A set of tiny React components for handling state with render props.
https://git.io/react-values
MIT License
1.01k stars 39 forks source link

change transform functions to maintain their references #7

Closed ianstormtaylor closed 6 years ago

ianstormtaylor commented 6 years ago

This is a first pass at fixing #6. Instead of composing <AnyValue>, the other components inherit from it instead. This enables them to store bound versions of their transforms on their instance, which means that the transform functions are needlessly recreated with each render.

Also happily looks like it slightly reduces the bundle size. Although this is just a first pass, I think it can be cleaned up and reduced even further with this method next.