File size: 441 Bytes
cfaaa6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { createContext, useContext } from 'react';

const WorkflowContext = createContext(null);

export function WorkflowProvider({ value, children }) {
  return <WorkflowContext.Provider value={value}>{children}</WorkflowContext.Provider>;
}

export function useWorkflow() {
  const context = useContext(WorkflowContext);

  if (!context) {
    throw new Error('useWorkflow must be used inside WorkflowProvider');
  }

  return context;
}