Rocky_Mountain_Vending/.pnpm-store/v10/files/f5/d1b8db561d9e800bcad2118fd30f3909a0905cce1bdbca1b215f42458cea045af29f0029ff47cfc7bef55d886a07aad4fd48f3057eb966744dd7086f6048df
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

32 lines
No EOL
1.4 KiB
Text

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useControlledValue = useControlledValue;
const react_1 = require("react");
/**
* A custom hook for managing both controlled and uncontrolled component states.
*
* This hook allows a component to support both controlled and uncontrolled
* states by determining whether the `controlledValue` is provided. If it is
* undefined, the hook falls back to using the internal state.
*
* @example
* // Uncontrolled usage
* const [value, setValue] = useControlledValue(0, undefined);
*
* // Controlled usage
* const [value, setValue] = useControlledValue(0, props.value);
*
* @template T - The type of the value.
* @param defaultValue The initial value for the uncontrolled state.
* @param controlledValue The value for the controlled state. If undefined, the
* component will use the uncontrolled state.
* @returns A tuple where the first element is the current value (either
* controlled or uncontrolled) and the second element is a setter function to
* update the value.
*/
function useControlledValue(defaultValue, controlledValue) {
const [uncontrolledValue, setValue] = (0, react_1.useState)(defaultValue);
const value = controlledValue === undefined ? uncontrolledValue : controlledValue;
return [value, setValue];
}
//# sourceMappingURL=useControlledValue.js.map