I'm getting a stragne error in TypeScript SafeAreaView component. I crated other refs for WebView and it doesn't fail, only seems to fail when assigned to the SafeAreaView component.
import { useRef, MutableRefObject } from 'react';
import { SafeAreaView } from 'react-native-safe-area-context';
...
...
const topSafeAreaViewRef = useRef(null);
...
...
<SafeAreaView ref={topSafeAreaViewRef} style={styles.container} edges={['top', 'right', 'left']} >
TS2322: Type '{ children: Element; ref: MutableRefObject; style: { flex: number; backgroundColor: any; }; edges: ("top" | "right" | "left")[]; }' is not assignable to type 'IntrinsicAttributes & ViewProps & { children?: ReactNode; mode?: "padding" | "margin" | undefined; edges?: readonly Edge[] | undefined; }'. Property 'ref' does not exist on type 'IntrinsicAttributes & ViewProps & { children?: ReactNode; mode?: "padding" | "margin" | undefined; edges?: readonly Edge[] | undefined; }'.
I need ref because I need to set setNativeProps on an external function
const handleOnLoadEnd = (
syntheticEvent: WebViewNavigationEvent | WebViewErrorEvent,
topSafeAreaViewRef: MutableRefObject<any>,
) => {
topSafeAreaViewRef.current.setNativeProps({
style:{
backgroundColor: Constants?.manifest?.extra?.webViewBackground,
}
});
};