Skip to content

Add Pan offset props to PropsToFilter#4026

Open
m-bert wants to merge 1 commit intomainfrom
@mbert/filter-pan-props
Open

Add Pan offset props to PropsToFilter#4026
m-bert wants to merge 1 commit intomainfrom
@mbert/filter-pan-props

Conversation

@m-bert
Copy link
Contributor

@m-bert m-bert commented Mar 16, 2026

Description

In Pan gesture, offset properties are handled differently than other props. Before they're sent to native side, they are mapped to separate start and end offset properties. This happens when offset props are present. However, if one explicitly sets value of offset property to undefined, e.g.:

activeOffsetY: Platform.OS === 'android' ? [-75, 75] : undefined,

the following warning can be observed:

WARN  [react-native-gesture-handler] activeOffsetY is not a valid property for PanGestureHandler and will be ignored.

This PR adds offset properties to our filter. With this change, warning no longer appears.

Fixes #4021

Note

It could also be solved by dynamically deleting undefined fields from config, but simply ignoring them sounds safer.

Test plan

Tested on the following code:
import React from 'react';
import { StyleSheet, Text, View, Platform } from 'react-native';
import { usePanGesture } from 'react-native-gesture-handler';

export default function EmptyExample() {
  const panGesture = usePanGesture({
    activeOffsetY: Platform.OS === 'android' ? [-75, 75] : undefined,
  });

  return (
    <View style={styles.container}>
      <Text style={{ fontSize: 64, opacity: 0.25 }}>😞</Text>
      <Text style={{ fontSize: 24, opacity: 0.25 }}>It's so empty here</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the v3 hooks config filtering so Pan offset props that may temporarily exist on the JS config object (especially when explicitly set to undefined) don’t trigger “invalid property” warnings during native config preparation.

Changes:

  • Add Pan offset props (activeOffsetX/Y, failOffsetX/Y) to PropsToFilter to suppress warnings when they appear in the config object prior to remapping/deletion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +81 to +86

// Pan offset props before remapping:
'activeOffsetY',
'failOffsetX',
'failOffsetY',
'activeOffsetX',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

or deleting these keys in transformOffsetProp even when the value is undefined

This is what I said in note in the description of the PR. I'm not sure if we want to do this, but it is an option (cc @j-piasecki)

Copy link
Member

Choose a reason for hiding this comment

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

Does passing undefined currently reset the value to the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When you pass undefined it is treated as if it wasn't passed at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or do you mean alternating between some value and undefined?

Copy link
Member

Choose a reason for hiding this comment

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

Or do you mean alternating between some value and undefined?

Yes

@m-bert m-bert requested a review from akwasniewski March 17, 2026 11:55
@m-bert m-bert requested a review from j-piasecki March 19, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Suggestion] [v3] Do not emit warning for undefined hook properties

4 participants