react-derive
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "react-derive", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Derived data for your memoizing pleasure", | ||
@@ -5,0 +5,0 @@ "main": "lib", |
@@ -15,3 +15,3 @@ # react-derive | ||
We can move the calculation of `a+b` to a decorator named `@derive` | ||
where we'll create the *deriver* function named sum `sum`. And because we | ||
where we'll create the *deriver* function named `sum`. And because we | ||
named the function `sum`, the deriver's result will be passed | ||
@@ -30,2 +30,4 @@ into the `Add` component via a prop likewise named `sum`. | ||
Note that the first and only argument to a *deriver* function is always `newProps`. | ||
But wait, every time the component renders, `sum` will recalculate even | ||
@@ -92,1 +94,5 @@ if `a` and `b` didn't change. To optimize, we can memoize the calculation with `@track` | ||
import {derive, track} from 'react-derive'; | ||
or when included via script tag it's available as the global variable `ReactDerive`: | ||
const {derive, track} = ReactDerive; |
9514
96