diff --git a/src/index.tsx b/src/index.tsx index 59e3c91..584c073 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -312,7 +312,7 @@ function checkCompatibleProps(props: ViewShotProperties): void { * method is attached to that node for the imperative `ref.current.capture()` * usage. */ -export type ViewShotRef = View & { +export type ViewShotRef = React.ComponentRef & { capture: () => Promise; }; @@ -328,7 +328,7 @@ const ViewShotComponent = forwardRef( style, } = props; - const rootRef = useRef(null); + const rootRef = useRef | null>(null); const rafRef = useRef(null); const lastCapturedURIRef = useRef(null); const resolveFirstLayoutRef = useRef<((layout: unknown) => void) | null>( @@ -378,7 +378,7 @@ const ViewShotComponent = forwardRef( ); const setRootRef = useCallback( - (node: View | null): void => { + (node: React.ComponentRef | null): void => { rootRef.current = node; if (node) (node as ViewShotRef).capture = capture; if (typeof ref === "function") { diff --git a/src/specs/NativeRNViewShot.ts b/src/specs/NativeRNViewShot.ts index cf1eeb7..260a5c8 100644 --- a/src/specs/NativeRNViewShot.ts +++ b/src/specs/NativeRNViewShot.ts @@ -1,6 +1,6 @@ import type {TurboModule} from "react-native"; import {TurboModuleRegistry, NativeModules} from "react-native"; -import {WithDefault} from "react-native/Libraries/Types/CodegenTypes"; +import type {CodegenTypes} from "react-native"; // Options stay `Object` (codegen → ReadableMap / NSDictionary). // Narrowing here would force a coordinated change to both native module @@ -8,7 +8,7 @@ import {WithDefault} from "react-native/Libraries/Types/CodegenTypes"; export interface Spec extends TurboModule { releaseCapture: (uri: string) => void; captureRef: ( - target: WithDefault, + target: CodegenTypes.WithDefault, withOptions: Object, ) => Promise; captureScreen: (options: Object) => Promise;