Total Complexity | 2 |
Complexity/F | 0 |
Lines of Code | 24 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* istanbul ignore file */ |
||
2 | import React from 'react' |
||
3 | |||
4 | const StateContext = React.createContext() |
||
5 | const DispatchContext = React.createContext() |
||
6 | |||
7 | const useState = () => { |
||
8 | const context = React.useContext(StateContext) |
||
9 | if (context === undefined) { |
||
10 | throw new Error('useState must be used within a Provider') |
||
11 | } |
||
12 | return context |
||
13 | } |
||
14 | |||
15 | const useDispatch = () => { |
||
16 | const context = React.useContext(DispatchContext) |
||
17 | if (context === undefined) { |
||
18 | throw new Error('useDispatch must be used within a Provider') |
||
19 | } |
||
20 | return context |
||
21 | } |
||
22 | |||
23 | export { StateContext, DispatchContext, useState, useDispatch } |
||
24 |