Skip to content
Open
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
11 changes: 8 additions & 3 deletions packages/react-native-gesture-handler/src/v3/hooks/useGesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export function useGesture<
config: BaseGestureConfig<TConfig, THandlerData, TExtendedHandlerData>
): SingleGesture<TConfig, THandlerData, TExtendedHandlerData> {
const handlerTag = useMemo(() => getNextHandlerTag(), []);
const disableReanimated = useMemo(() => config.disableReanimated, []);
const previousConfig = useMemo(() => config, []);

if (config.disableReanimated !== disableReanimated) {
if (config.disableReanimated !== previousConfig.disableReanimated) {
throw new Error(
tagMessage(
'The "disableReanimated" property must not be changed after the handler is created.'
Expand All @@ -42,7 +42,12 @@ export function useGesture<
}

// This has to be done ASAP as other hooks depend `shouldUseReanimatedDetector`.
prepareConfig(config);
//
// We only need to prepare config once. If Reanimated is used and we try to preapre the same config again,
Comment thread
m-bert marked this conversation as resolved.
Outdated
// it will result in warnings, as config has already been sent to the native side (i.e. config is frozen).
if (config !== previousConfig) {
prepareConfig(config);
}
Comment on lines +52 to +54
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// TODO: Call only necessary hooks depending on which callbacks are defined (?)
const { jsEventHandler, reanimatedEventHandler, animatedEventHandler } =
Expand Down
Loading