import * as React from "react"; import { View } from "react-native"; type Props = { inViewport: boolean; Component: React.ComponentType; id: string | number; } & Record; // this needs to be a class component in order for the ViewTracker // component to work properly, as it requires to have a ref export class RenderInViewport extends React.PureComponent { render() { const { inViewport, Component, id, ...rest } = this.props; return inViewport ? : ; } }