Deku timer component (higher-order)
A deku higher-order timer component
Keep your components simple, testable and composable by using higher-order components. This higher-order timer component will re-render your component at the desire rate (in milliseconds).
This higher-order component takes care of when to call render on your component, so your component has only to care about the rendering logic.
A higher-order component is just a function that takes an existing component and returns another component that wraps it.
Read about higher-order components here (applies to deku as well): Mixins Are Dead. Long Live Composition.
Applications
- Countdowns (time remaining)
- Timers (time elapsed)
- Forcing updates / refresh of time-based contents
Installation
npm install --save deku-timer
Usage
Create a new component by wrapping your component with timer
HOC. Alongside the properties you specify, the created component will receive a tick
property, the specified delay
value and a stop
function.
;; { return ;} const Timer1 = render: myComponent ;const Timer2 = render: myComponent ; const app = ; ;