import * as React from "react";
import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks";
import { ZappPipesScreenContext } from "../../Contexts";

export function withDefaultScreenContext(Component: React.ComponentType<any>) {
  return function WithDefaultScreenContext(props: any) {
    const screenId = props.screenId;
    const rivers = useRivers();

    return (
      <ZappPipesScreenContext.Provider initialContextValue={rivers[screenId]}>
        <Component {...props} />
      </ZappPipesScreenContext.Provider>
    );
  };
}
