import * as React from "react";
import { useIsoLayoutEffect } from "../../../utils/esm/useIsoLayoutEffect.js";
import { useStableCallback } from "../../../utils/esm/useStableCallback.js";
function useValueChanged(value, onChange) {
  const valueRef = React.useRef(value);
  const onChangeCallback = useStableCallback(onChange);
  useIsoLayoutEffect(() => {
    if (valueRef.current === value) {
      return;
    }
    onChangeCallback(valueRef.current);
  }, [value, onChangeCallback]);
  useIsoLayoutEffect(() => {
    valueRef.current = value;
  }, [value]);
}
export {
  useValueChanged
};
//# sourceMappingURL=useValueChanged.js.map
