react-native-reanimated
Advanced tools
Comparing version 1.3.2 to 1.4.0
10
mock.js
@@ -14,3 +14,3 @@ /** | ||
const NOOP = () => undefined; | ||
function NOOP() {} | ||
@@ -41,3 +41,7 @@ class Code extends React.Component { | ||
Node: NOOP, | ||
Value: NOOP, | ||
Value: function() { | ||
return { | ||
setValue: NOOP, | ||
}; | ||
}, | ||
@@ -102,2 +106,4 @@ Extrapolate: { | ||
proc: () => NOOP, | ||
useCode: NOOP, | ||
@@ -104,0 +110,0 @@ createAnimatedComponent: Component => Component, |
{ | ||
"name": "react-native-reanimated", | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"description": "More powerful alternative to Animated library for React Native.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -259,3 +259,3 @@ // Project: https://github.com/kmagiera/react-native-reanimated | ||
message: string, | ||
value: Adaptable<T>, | ||
value: AnimatedNode<T>, | ||
): AnimatedNode<T>; | ||
@@ -333,3 +333,3 @@ export function onChange( | ||
export function useCode( | ||
exec: AnimatedNode<number>, | ||
exec: () => AnimatedNode<number>, | ||
deps: Array<any>, | ||
@@ -336,0 +336,0 @@ ): void |
@@ -227,3 +227,3 @@ # react-native-reanimated | ||
```js | ||
Animated.useCode(node, deps) | ||
Animated.useCode(() => node, deps) | ||
``` | ||
@@ -234,3 +234,3 @@ It's passed an animated node and an array of dependencies, and updates that node both when the component mounts and every time a value in that array changes. It does nothing on versions of React Native that don't support hooks (<0.59). | ||
Animated.useCode( | ||
set(transX1, add(_transX, offset)), | ||
() => set(transX1, add(_transX, offset)), | ||
[offset] | ||
@@ -240,2 +240,4 @@ ); | ||
We recommend to use `useCode()` with the `react-hooks/exhaustive-deps` [eslint rule](https://www.npmjs.com/package/eslint-plugin-react-hooks). | ||
## Event handling with reanimated nodes | ||
@@ -910,2 +912,10 @@ | ||
## Jest | ||
In order to use `react-native-reanimated` with Jest, you need to add the following mock implementation at the top of your test: | ||
```js | ||
jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock')); | ||
``` | ||
## License | ||
@@ -912,0 +922,0 @@ |
@@ -5,2 +5,4 @@ import AnimatedNode from './AnimatedNode'; | ||
import invariant from 'fbjs/lib/invariant'; | ||
class AnimatedSet extends AnimatedNode { | ||
@@ -12,2 +14,3 @@ _what; | ||
super({ type: 'set', what: what.__nodeID, value: value.__nodeID }, [value]); | ||
invariant(!what._constant, 'Value to be set cannot be constant'); | ||
this._what = what; | ||
@@ -14,0 +17,0 @@ this._value = value; |
@@ -7,3 +7,8 @@ import React from 'react'; | ||
React.useEffect(() => { | ||
const animatedAlways = always(exec); | ||
if (typeof exec !== 'function') { | ||
console.warn( | ||
'useCode() first argument should be a function that returns an animation node.' | ||
); | ||
} | ||
const animatedAlways = always(typeof exec === 'function' ? exec() : exec); | ||
animatedAlways.__attach(); | ||
@@ -10,0 +15,0 @@ return () => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
357538
3930
927