import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
/* "use client" */

import { useEffect, useRef, useState } from 'react';
var useCurrentState = function useCurrentState(initialState) {
  var _useState = useState(function () {
      return typeof initialState === 'function' ? initialState() : initialState;
    }),
    _useState2 = _slicedToArray(_useState, 2),
    state = _useState2[0],
    setState = _useState2[1];
  var ref = useRef(initialState);
  useEffect(function () {
    ref.current = state;
  }, [state]);
  var setValue = function setValue(val) {
    var result = typeof val === 'function' ? val(ref.current) : val;
    ref.current = result;
    setState(result);
  };
  return [state, setValue, ref];
};
export default useCurrentState;