You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
portainer/app/react/components/datatables/RowContext.tsx

25 lines
621 B

import { createContext, PropsWithChildren, useContext } from 'react';
export function createRowContext<TContext>() {
const Context = createContext<TContext | null>(null);
Context.displayName = 'RowContext';
return { RowProvider, useRowContext };
function RowProvider({
children,
context,
}: PropsWithChildren<{ context: TContext }>) {
return <Context.Provider value={context}>{children}</Context.Provider>;
}
function useRowContext() {
const context = useContext(Context);
if (!context) {
throw new Error('should be nested under RowProvider');
}
return context;
}
}