Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
39 lines
876 B
Plaintext
39 lines
876 B
Plaintext
'use client';
|
|
|
|
import { c as _c } from "react/compiler-runtime";
|
|
import { useEffect, useRef, useState } from 'react';
|
|
export function useControllableState(propValue, fallbackValue) {
|
|
const $ = _c(5);
|
|
const [localValue, setLocalValue] = useState(propValue);
|
|
const initialRenderRef = useRef(true);
|
|
let t0;
|
|
let t1;
|
|
if ($[0] !== propValue) {
|
|
t0 = () => {
|
|
if (initialRenderRef.current) {
|
|
initialRenderRef.current = false;
|
|
return;
|
|
}
|
|
setLocalValue(propValue);
|
|
};
|
|
t1 = [propValue];
|
|
$[0] = propValue;
|
|
$[1] = t0;
|
|
$[2] = t1;
|
|
} else {
|
|
t0 = $[1];
|
|
t1 = $[2];
|
|
}
|
|
useEffect(t0, t1);
|
|
const t2 = localValue ?? fallbackValue;
|
|
let t3;
|
|
if ($[3] !== t2) {
|
|
t3 = [t2, setLocalValue];
|
|
$[3] = t2;
|
|
$[4] = t3;
|
|
} else {
|
|
t3 = $[4];
|
|
}
|
|
return t3;
|
|
}
|
|
//# sourceMappingURL=useControllableState.js.map |