import*as e from"react";import{useCallbackRef as t}from"../../react-use-callback-ref/dist/index.js";function n({prop:n,defaultProp:o,onChange:r=(()=>{})}){const[u,a]=function({defaultProp:n,onChange:o}){const r=e.useState(n),[u]=r,a=e.useRef(u),c=t(o);return e.useEffect((()=>{a.current!==u&&(c(u),a.current=u)}),[u,a,c]),r}({defaultProp:o,onChange:r}),c=void 0!==n,f=c?n:u,s=t(r);return[f,e.useCallback((e=>{if(c){const t="function"==typeof e?e(n):e;t!==n&&s(t)}else a(e)}),[c,n,a,s])]}export{n as useControllableState};
//# sourceMappingURL=index.js.map
