ReactNative TypeScript hooks组件的实例化
实例化 参考下面代码
import React, {useImperativeHandle} from 'react';
import {
View,
} from 'react-native';
interface InstanceProps {
}
export interface InstanceRef {
onRefresh: () => void;
}
const InstanceClass = (
props: InstanceProps,
ref: React.Ref<InstanceRef>,
) => {
useImperativeHandle(ref, () => ({
onRefresh: () => onRefresh(),
}));
const onRefresh =()=>{}
return (
<View/>
);
};
export const InstanceExample = React.forwardRef<
InstanceRef,
InstanceProps
>(InstanceClass);