Closed maximpostnikov closed 4 days ago
This PR addresses an issue related to #2023.
It introduces the ability to explicitly define types for data passed through refs, ensuring strict typing for this data.
const alertModalPrimaryRef = useRef<BottomSheetModal<AlertModalContentProps>>(null); const handleUpdatePress = () => { alertModalPrimaryRef.current?.present({ type: 'success', test: true, // Throws error because `test` isn't defined in `AlertModalContentProps` }) }
Additionally, it would be beneficial if the data passed through children could also be typed.
export type AlertModalContentProps = { type: 'success' | 'error' } ... <BottomSheetModal<AlertModalContentProps> name={name} ref={ref}> {({ data }) => ( <BottomSheetView> {data && <AlertModalContent {...data} />} </BottomSheetView> )} </BottomSheetModal>
thanks @maximpostnikov for improving the types 🙌
Motivation
This PR addresses an issue related to #2023.
It introduces the ability to explicitly define types for data passed through refs, ensuring strict typing for this data.
Additionally, it would be beneficial if the data passed through children could also be typed.