import { PropsWithChildren, createContext, useContext } from 'react';

const FooterRenderAreaContext = createContext(false);

/** Render area in which data table footer is rendered */
export function FooterRenderArea({ children }: PropsWithChildren<{}>) {
  return <FooterRenderAreaContext.Provider value={true}>{children}</FooterRenderAreaContext.Provider>;
}

/** Return `true` if current component is located inside {@link FooterRenderArea} */
export function useIsFooterRenderArea() {
  return useContext(FooterRenderAreaContext);
}
