Open marcshilling opened 8 months ago
This works as expected with an iOS version lower than 17.4, so something definitely has broken in iOS 17.4
I stumbled on the same thing and it looks like UIRefreshControl
needs to be set on a scroll view before the tintColor
is set.
Got around to writing a patch for this here https://github.com/bluesky-social/social-app/pull/5605 based on @dus7's finding. Thanks!
Still an issue in iOS 18 unfortunately.
Here's my workaround in pure react:
import { useState, useEffect } from "react";
import {
RefreshControl as RNRefreshControl,
RefreshControlProps as RNRefreshControlProps
} from "react-native";
export default function RefreshControl(props: RNRefreshControlProps) {
const [tintColor, setTintColor] = useState<RNRefreshControlProps["tintColor"]>();
// Shameless workaround to set the tint color after the component is rendered.
// See https://github.com/facebook/react-native/issues/43388
useEffect(() => {
setTintColor(props.tintColor);
// If you want a default tintColor:
// setTintColor(props.tintColor || MY_DEFAULT_TINT_COLOR);
}, [props.tintColor]);
return (
<RNRefreshControl
{...props}
tintColor={tintColor}
/>
);
}
Explaining the workaround:
RNRefreshControl
is mounted without a tintColor
since we initialize the tintColor
state without a valueRNRefreshControl
is already mounted to update the tintColor
to the props.tintColor
Tested on a real device and it worked.
Description
On iOS, it's expected that the system gives small haptic feedback when using pull-to-refresh. This works by default when using
<RefreshControl>
. However, when passing atintColor
prop to<RefreshControl>
, the haptics don't play.I don't have another device to confirm, but I feel like this may have just started recently, possibly with iOS 17.4.
Steps to reproduce
Use a RefreshControl with a tintColor prop on a real iOS device and observe that the haptic feedback does not play. Comment out the tintColor prop, reload the app (fast refresh doesn't have an effect), and then observe the haptic feedback works.
React Native Version
0.73.5
Affected Platforms
Runtime - iOS
Device I'm testing on is an iPhone 15 Pro on iOS 17.4
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/marcshilling/react-native-refresh-control-haptics-bug
Screenshots and Videos
No response