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 4646 "@babel/runtime" : " ^7.11.1" ,
4747 "classnames" : " ^2.2.1" ,
4848 "rc-resize-observer" : " ^1.0.0" ,
49- "rc-util" : " ^5.15.0 "
49+ "rc-util" : " ^5.19.2 "
5050 },
5151 "devDependencies" : {
5252 "@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' ;
22import raf from 'rc-util/lib/raf' ;
3+ import useState from 'rc-util/lib/hooks/useState' ;
34
45/**
56 * 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';
89export function useBatchFrameState ( ) {
910 const [ , forceUpdate ] = useState ( { } ) ;
1011 const statesRef = useRef < any [ ] > ( [ ] ) ;
11- const destroyRef = useRef < boolean > ( false ) ;
1212 let walkingIndex = 0 ;
1313 let beforeFrameId : number = 0 ;
1414
15- useEffect (
16- ( ) => ( ) => {
17- destroyRef . current = true ;
18- } ,
19- [ ] ,
20- ) ;
21-
2215 function createState < T > (
2316 defaultValue : T ,
2417 ) : [ T , ( value : T | ( ( origin : T ) => T ) ) => void ] {
@@ -41,9 +34,7 @@ export function useBatchFrameState() {
4134
4235 // Flush with batch
4336 beforeFrameId = raf ( ( ) => {
44- if ( ! destroyRef . current ) {
45- forceUpdate ( { } ) ;
46- }
37+ forceUpdate ( { } , true ) ;
4738 } ) ;
4839 }
4940
You can’t perform that action at this time.
0 commit comments