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

Add assert to props whitelists #5156

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 12 additions & 1 deletion src/ConfigHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
import { configureProps as jsiConfigureProps } from './reanimated2/core';
import { jsiConfigureProps } from './reanimated2/core';

/**
* Styles allowed to be direcly updated in UI thread
Expand Down Expand Up @@ -121,7 +121,18 @@ let NATIVE_THREAD_PROPS_WHITELIST: Record<string, boolean> = {
placeholderTextColor: true,
};

function assertNoOverlapInLists() {
for (const key in NATIVE_THREAD_PROPS_WHITELIST) {
if (key in UI_THREAD_PROPS_WHITELIST) {
throw new Error(
`[Reanimated] Property \`${key}\` was whitelisted both as UI and native prop. Please remove it from one of the lists.`
);
}
}
}

function configureProps(): void {
assertNoOverlapInLists();
piaskowyk marked this conversation as resolved.
Show resolved Hide resolved
jsiConfigureProps(
Object.keys(UI_THREAD_PROPS_WHITELIST),
Object.keys(NATIVE_THREAD_PROPS_WHITELIST)
Expand Down
5 changes: 4 additions & 1 deletion src/reanimated2/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ export function setShouldAnimateExitingForTag(
);
}

export function configureProps(uiProps: string[], nativeProps: string[]): void {
export function jsiConfigureProps(
uiProps: string[],
nativeProps: string[]
): void {
if (!nativeShouldBeMock()) {
NativeReanimatedModule.configureProps(uiProps, nativeProps);
}
Expand Down