Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove top level is_fabric check #5779

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/createAnimatedComponent/createAnimatedComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import type { FlatList, FlatListProps } from 'react-native';
import { addHTMLMutationObserver } from '../reanimated2/layoutReanimation/web/domUtils';

const IS_WEB = isWeb();
const IS_FABRIC = isFabric();

if (IS_WEB) {
configureWebLayoutAnimations();
Expand Down Expand Up @@ -268,7 +267,7 @@ export function createAnimatedComponent(
if (this.props.animatedProps?.viewDescriptors) {
this.props.animatedProps.viewDescriptors.remove(this._viewTag);
}
if (IS_FABRIC) {
if (isFabric()) {
removeFromPropsRegistry(this._viewTag);
}
}
Expand Down Expand Up @@ -359,7 +358,7 @@ export function createAnimatedComponent(

viewConfig = hostInstance?.viewConfig;

if (IS_FABRIC) {
if (isFabric()) {
shadowNodeWrapper = getShadowNodeWrapperFromRef(this);
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/reanimated2/PropsRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import { isFabric } from './PlatformChecker';
import { runOnUI } from './threads';

const IS_FABRIC = isFabric();

let VIEW_TAGS: number[] = [];

export function removeFromPropsRegistry(viewTag: number) {
Expand All @@ -14,7 +12,7 @@ export function removeFromPropsRegistry(viewTag: number) {
}

function flush() {
if (__DEV__ && !IS_FABRIC) {
if (__DEV__ && !isFabric()) {
throw new Error('[Reanimated] PropsRegistry is only available on Fabric.');
}
runOnUI(removeFromPropsRegistryOnUI)(VIEW_TAGS);
Expand Down
3 changes: 1 addition & 2 deletions src/reanimated2/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export type { WorkletRuntime } from './runtimes';
export { makeShareable, makeShareableCloneRecursive } from './shareables';
export { makeMutable } from './mutables';

const IS_FABRIC = isFabric();
const SHOULD_BE_USE_WEB = shouldBeUseWeb();

/**
Expand All @@ -56,7 +55,7 @@ if (SHOULD_BE_USE_WEB) {
}

export function getViewProp<T>(viewTag: number, propName: string): Promise<T> {
if (IS_FABRIC) {
if (isFabric()) {
throw new Error(
'[Reanimated] `getViewProp` is not supported on Fabric yet.'
);
Expand Down
9 changes: 4 additions & 5 deletions src/reanimated2/hook/useAnimatedRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { Platform, findNodeHandle } from 'react-native';
import type { ScrollView, FlatList } from 'react-native';
import { isFabric, isWeb } from '../PlatformChecker';

const IS_FABRIC = isFabric();
const IS_WEB = isWeb();

interface MaybeScrollableComponent extends Component {
Expand All @@ -25,15 +24,15 @@ interface MaybeScrollableComponent extends Component {
}

function getComponentOrScrollable(component: MaybeScrollableComponent) {
if (IS_FABRIC && component.getNativeScrollRef) {
if (isFabric() && component.getNativeScrollRef) {
return component.getNativeScrollRef();
} else if (!IS_FABRIC && component.getScrollableNode) {
} else if (!isFabric() && component.getScrollableNode) {
return component.getScrollableNode();
}
return component;
}

const getTagValueFunction = IS_FABRIC
const getTagValueFunction = isFabric()
? getShadowNodeWrapperFromRef
: findNodeHandle;

Expand Down Expand Up @@ -62,7 +61,7 @@ export function useAnimatedRef<
: getTagValueFunction(getComponentOrScrollable(component));
fun.current = component;
// viewName is required only on iOS with Paper
if (Platform.OS === 'ios' && !IS_FABRIC) {
if (Platform.OS === 'ios' && !isFabric()) {
viewName.value =
(component as MaybeScrollableComponent)?.viewConfig
?.uiViewClassName || 'RCTView';
Expand Down
Loading