File tree Expand file tree Collapse file tree 2 files changed +4
-13
lines changed Expand file tree Collapse file tree 2 files changed +4
-13
lines changed Original file line number Diff line number Diff line change 46
46
"@babel/runtime" : " ^7.11.1" ,
47
47
"classnames" : " ^2.2.1" ,
48
48
"rc-resize-observer" : " ^1.0.0" ,
49
- "rc-util" : " ^5.15.0 "
49
+ "rc-util" : " ^5.19.2 "
50
50
},
51
51
"devDependencies" : {
52
52
"@types/classnames" : " ^2.2.9" ,
Original file line number Diff line number Diff line change 1
- import { useRef , useState , useEffect } from 'react' ;
1
+ import { useRef } from 'react' ;
2
2
import raf from 'rc-util/lib/raf' ;
3
+ import useState from 'rc-util/lib/hooks/useState' ;
3
4
4
5
/**
5
6
* State generate. Return a `setState` but it will flush all state with one render to save perf.
@@ -8,17 +9,9 @@ import raf from 'rc-util/lib/raf';
8
9
export function useBatchFrameState ( ) {
9
10
const [ , forceUpdate ] = useState ( { } ) ;
10
11
const statesRef = useRef < any [ ] > ( [ ] ) ;
11
- const destroyRef = useRef < boolean > ( false ) ;
12
12
let walkingIndex = 0 ;
13
13
let beforeFrameId : number = 0 ;
14
14
15
- useEffect (
16
- ( ) => ( ) => {
17
- destroyRef . current = true ;
18
- } ,
19
- [ ] ,
20
- ) ;
21
-
22
15
function createState < T > (
23
16
defaultValue : T ,
24
17
) : [ T , ( value : T | ( ( origin : T ) => T ) ) => void ] {
@@ -41,9 +34,7 @@ export function useBatchFrameState() {
41
34
42
35
// Flush with batch
43
36
beforeFrameId = raf ( ( ) => {
44
- if ( ! destroyRef . current ) {
45
- forceUpdate ( { } ) ;
46
- }
37
+ forceUpdate ( { } , true ) ;
47
38
} ) ;
48
39
}
49
40
You can’t perform that action at this time.
0 commit comments