UNPKG

react-native-reanimated

Version:

More powerful alternative to Animated library for React Native.

60 lines (58 loc) 1.83 kB
import { isChromeDebugger, isJest, isWeb, shouldBeUseWeb } from './PlatformChecker'; import { _updatePropsJS } from './js-reanimated'; import { processColorsInProps } from './Colors'; const IS_NATIVE = !shouldBeUseWeb(); export let setNativeProps; if (isWeb()) { setNativeProps = (_animatedRef, _updates) => { const component = _animatedRef(); _updatePropsJS(_updates, { _component: component }); }; } else if (IS_NATIVE && global._IS_FABRIC) { setNativeProps = (animatedRef, updates) => { 'worklet'; if (!_WORKLET) { console.warn('[Reanimated] setNativeProps() can only be used on the UI runtime.'); return; } const shadowNodeWrapper = animatedRef(); processColorsInProps(updates); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion _updatePropsFabric([{ shadowNodeWrapper, updates }]); }; } else if (IS_NATIVE) { setNativeProps = (animatedRef, updates) => { 'worklet'; if (!_WORKLET) { console.warn('[Reanimated] setNativeProps() can only be used on the UI runtime.'); return; } const tag = animatedRef(); const name = animatedRef.viewName.value; processColorsInProps(updates); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion _updatePropsPaper([{ tag, name, updates }]); }; } else if (isChromeDebugger()) { setNativeProps = () => { console.warn('[Reanimated] setNativeProps() is not supported with Chrome Debugger.'); }; } else if (isJest()) { setNativeProps = () => { console.warn('[Reanimated] setNativeProps() is not supported with Jest.'); }; } else { setNativeProps = () => { console.warn('[Reanimated] setNativeProps() is not supported on this configuration.'); }; } //# sourceMappingURL=SetNativeProps.js.map