import { useLayoutVersion } from "@applicaster/zapp-react-native-utils/reactHooks";
import React from "react";
import { withPipesV1DataLoader } from "./withPipesV1DataLoader";

export const withRiverDataLoader = (
  WrappedComponent: React.ComponentType<any>
) => {
  return function WithRiverDataLoaderComponent(props) {
    const isV2 = useLayoutVersion({ isV2: true });

    if (isV2) {
      return <WrappedComponent {...props} />;
    }

    return withPipesV1DataLoader(WrappedComponent)(props);
  };
};
