react-native-reanimated#always TypeScript Examples
The following examples show how to use
react-native-reanimated#always.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Bar.tsx From expo-progress with MIT License | 6 votes |
function useCode(nodeFactory, dependencies) {
if (!(React.useEffect instanceof Function)) return;
// @ts-ignore
React.useEffect(() => {
// check and correct 1st parameter
if (!(nodeFactory instanceof Function)) {
console.warn(
'useCode() first argument should be a function that returns an animation node.'
);
const node = nodeFactory;
nodeFactory = () => node;
}
let node = nodeFactory();
if (node) {
// allow factory to return array
if (node instanceof Array) node = block(node);
const animatedAlways = always(node);
animatedAlways.__attach();
// todo: upstream this
if (Platform.OS === 'web') {
animatedAlways.__onEvaluate();
}
// return undo function
return () => animatedAlways.__detach();
}
}, dependencies);
}