react-native-paper
react-native-paper copied to clipboard
fix: wrong types for onPress and onLongPress and bug in example app
Summary
I'm working on a navigation library on top of react-router-dom and react-native-navigation. But the Link component I'm using won't work well with the onPress of react-native-paper in typescript since the event is not defined in typescript (but is provided to the function)
const onPress = React.useCallback(
(event: GestureResponderEvent) => {
if (!event.defaultPrevented) {
event.preventDefault();
navigation.push(to, params);
}
},
[navigation, to, params],
);
Types of property 'onPress' are incompatible. Type '(e: GestureResponderEvent) => any' is not assignable to type '() => void'.
I decided to fix it everywhere so I can use links on some places or it just good to provide it to users so can they can provide preventDefault() or things like that.
Test plan
Hey @RichardLindhout, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

This fixes a bug in the example app too since the android button is not switchable at all it is always 'checked' after first click since the argument is only an event and not the previous status.
Hello 👋, this pull request has been open for more than 2 months with no activity on it. If you think this is still necessary with the latest version, please comment and ping a maintainer to get this reviewed, otherwise it will be closed automatically in 7 days.
Hello 👋, this pull request has been open for more than 2 months with no activity on it. If you think this is still necessary with the latest version, please comment and ping a maintainer to get this reviewed, otherwise it will be closed automatically in 7 days.
Closing due to your second PR https://github.com/callstack/react-native-paper/pull/3484 😓
ToggleButton
's I will handle separately.