node_modules/ant-design-vue/lib/_util/hooks/useLayoutState.js
/**
 * Execute code before next frame but async
 */
Execute code before next frame but async
Execute code before next frame but async
function useLayoutState(defaultState) {
  var stateRef = (0, _vue.ref)(defaultState);
  var tempState = stateRef.value;
  var updateBatchRef = [];
  var rafRef = (0, _vue.ref)();
  function setFrameState(updater) {
    _raf.default.cancel(rafRef.value);
    updateBatchRef.push(updater);
    rafRef.value = (0, _raf.default)(function () {
      var prevBatch = updateBatchRef; 
      updateBatchRef = [];
      prevBatch.forEach(function (batchUpdater) {
        tempState = batchUpdater(tempState);
      }); 
      stateRef.value = tempState; 
    });
  }
  (0, _vue.onBeforeUnmount)(function () {
    _raf.default.cancel(rafRef.value);
  });
  return [stateRef, setFrameState];
}
function useLayoutState ( defaultState ) { var stateRef = ( 0 , _vue . ref ) ( defaultState ) ; var tempState = stateRef . value ; var updateBatchRef = [ ] ; var rafRef = ( 0 , _vue . ref ) ( ) ; function setFrameState ( updater ) { _raf . default . cancel ( rafRef . value ) ; updateBatchRef . push ( updater ) ; rafRef . value = ( 0 , _raf . default ) ( function ( ) { var prevBatch = updateBatchRef ; updateBatchRef = [ ] ; prevBatch . forEach ( function ( batchUpdater ) { tempState = batchUpdater ( tempState ) ; } ) ; stateRef . value = tempState ; } ) ; } ( 0 , _vue . onBeforeUnmount ) ( function ( ) { _raf . default . cancel ( rafRef . value ) ; } ) ; return [ stateRef , setFrameState ] ; }
Execute code before next frame but async
Execute code before next frame but async
// const prevState = stateRef.value; // if (tempState !== stateRef.value) { // }