mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
made lab use provider and context
This commit is contained in:
parent
cb314e9f8d
commit
96f1529f2b
9 changed files with 129 additions and 56 deletions
34
src/utils/context/LabContextProvider.tsx
Normal file
34
src/utils/context/LabContextProvider.tsx
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { ILabNode } from '~/redux/lab/types';
|
||||
import React, { createContext, FC, useContext } from 'react';
|
||||
import { INode, ITag } from '~/redux/types';
|
||||
|
||||
export interface LabContextProps {
|
||||
isLoading: boolean;
|
||||
nodes: ILabNode[];
|
||||
count: number;
|
||||
onLoadMore: () => void;
|
||||
|
||||
tags: ITag[];
|
||||
heroes: Partial<INode>[];
|
||||
isLoadingStats: boolean;
|
||||
updates: Partial<INode>[];
|
||||
}
|
||||
|
||||
const defaultValues: LabContextProps = {
|
||||
isLoading: false,
|
||||
nodes: [],
|
||||
count: 0,
|
||||
onLoadMore: () => {},
|
||||
tags: [],
|
||||
heroes: [],
|
||||
isLoadingStats: false,
|
||||
updates: [],
|
||||
};
|
||||
|
||||
const LabContext = createContext<LabContextProps>(defaultValues);
|
||||
|
||||
export const LabContextProvider: FC<LabContextProps> = ({ children, ...rest }) => (
|
||||
<LabContext.Provider value={rest}>{children}</LabContext.Provider>
|
||||
);
|
||||
|
||||
export const useLabContext = () => useContext(LabContext);
|
Loading…
Add table
Add a link
Reference in a new issue