clean
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import type useWorkspaceSelection from './useWorkspaceSelection';
|
||||
|
||||
type WorkspaceSelectionValue = ReturnType<typeof useWorkspaceSelection> | null;
|
||||
|
||||
const WorkspaceSelectionContext = createContext<WorkspaceSelectionValue>(null);
|
||||
|
||||
export const WorkspaceSelectionProvider: React.FC<{ value: NonNullable<WorkspaceSelectionValue>; children: React.ReactNode }>
|
||||
= ({ value, children }) => (
|
||||
<WorkspaceSelectionContext.Provider value={value}>
|
||||
{children}
|
||||
</WorkspaceSelectionContext.Provider>
|
||||
);
|
||||
|
||||
export const useWorkspaceSelectionContext = () => {
|
||||
const context = useContext(WorkspaceSelectionContext);
|
||||
if (!context) {
|
||||
throw new Error('useWorkspaceSelectionContext must be used within a WorkspaceSelectionProvider');
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
export default WorkspaceSelectionContext;
|
||||
Reference in New Issue
Block a user