Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

React createRef not assignable to type MutableRefObject in React Native Actions Sheet ref prop

$
0
0

I am using react-native-actions-sheet v0.5.1 which recently added Typescript support:

export default function MyFunc(){   const actionSheetRef = createRef<ActionSheet>()   useEffect(() => {        actionSheetRef.current?.setModalVisible(props.open)   }, [props.open])   return (<><ActionSheet                ref={actionSheetRef}                onClose={props.onClose}>            // more code here  ....<>)}

But with the new versions, now my code gets a Typescript error on the ref inside the <ActionSheet>:

Type 'RefObject<ActionSheet>' is not assignable to type '(string & MutableRefObject<{ setModalVisible(visible?: boolean | undefined): void; show(): void; hide(): void; handleChildScrollEnd(): void; snapToOffset(offset: number): void; }>) | (RefObject<...> & MutableRefObject<...>) | (((instance: ActionSheet | null) => void) & MutableRefObject<...>) | undefined'.  Type 'RefObject<ActionSheet>' is not assignable to type '((instance: ActionSheet | null) => void) & MutableRefObject<{ setModalVisible(visible?: boolean | undefined): void; show(): void; hide(): void; handleChildScrollEnd(): void; snapToOffset(offset: number): void; }>'.    Type 'RefObject<ActionSheet>' is not assignable to type '(instance: ActionSheet | null) => void'.      Type 'RefObject<ActionSheet>' provides no match for the signature '(instance: ActionSheet | null): void'.

Any idea how to solve?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>