mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 06:49:40 +02:00
refactor(containers): migrate view to react [EE-2212] (#6577)
Co-authored-by: LP B <xAt0mZ@users.noreply.github.com>
This commit is contained in:
parent
5ee570e075
commit
bed4257194
71 changed files with 1616 additions and 875 deletions
23
app/react/components/datatables/RowContext.tsx
Normal file
23
app/react/components/datatables/RowContext.tsx
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { createContext, PropsWithChildren, useContext } from 'react';
|
||||
|
||||
export function createRowContext<TContext>() {
|
||||
const Context = createContext<TContext | null>(null);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue