Skip to content

Commit

Permalink
📚 Fix Clock example (#152)
Browse files Browse the repository at this point in the history
Put the `runTimer` array in a `block`
  • Loading branch information
Krisztiaan authored and osdnk committed Dec 17, 2018
1 parent 72b1792 commit e44a871
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,8 @@ The example below shows a component that renders:
```js
import Animated, { Easing } from 'react-native-reanimated';

const { Clock, Value, set, cond, startClock, clockRunning, timing, debug, stopClock, block } = Animated

function runTiming(clock, value, dest) {
const state = {
finished: new Value(0),
Expand All @@ -635,7 +637,7 @@ function runTiming(clock, value, dest) {
easing: Easing.inOut(Easing.ease),
};

return [
return block([
cond(clockRunning(clock), 0, [
// If the clock isn't running we reset all the animation params and start the clock
set(state.finished, 0),
Expand All @@ -651,7 +653,7 @@ function runTiming(clock, value, dest) {
cond(state.finished, debug('stop clock', stopClock(clock))),
// we made the block return the updated position
state.position,
];
]);
}

export class AnimatedBox extends Component {
Expand Down

0 comments on commit e44a871

Please sign in to comment.