File tree 1 file changed +4
-5
lines changed
1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { useState , useEffect } from 'react'
2
2
import { renderHook } from '../src'
3
3
4
- type throwError = Error | boolean | undefined
5
4
describe ( 'error hook tests' , ( ) => {
6
- function useError ( throwError : throwError ) {
5
+ function useError ( throwError : boolean ) {
7
6
if ( throwError ) {
8
7
throw new Error ( 'expected' )
9
8
}
10
9
return true
11
10
}
12
11
13
- function useAsyncError ( throwError : throwError ) {
14
- const [ value , setValue ] = useState < throwError > ( )
12
+ function useAsyncError ( throwError : boolean ) {
13
+ const [ value , setValue ] = useState < boolean > ( )
15
14
useEffect ( ( ) => {
16
15
const timeout = setTimeout ( ( ) => setValue ( throwError ) , 100 )
17
16
return ( ) => clearTimeout ( timeout )
18
17
} , [ throwError ] )
19
18
return useError ( value )
20
19
}
21
20
22
- function useEffectError ( throwError : throwError ) {
21
+ function useEffectError ( throwError : boolean ) {
23
22
useEffect ( ( ) => {
24
23
useError ( throwError )
25
24
} , [ throwError ] )
You can’t perform that action at this time.
0 commit comments