UNPKG

541 BJavaScriptView Raw
1/**
2 * Determines whether a component is controlled.
3 * @param props - Component props
4 * @param valueProp - Prop containing the controlled value
5 * @returns true if controlled, false if uncontrolled
6 */
7export function isControlled(props, valueProp) {
8 // React's built-in <input> considers a prop to be provided if its value is non-null/undefined.
9 // Mirror that behavior here (rather than checking for just undefined).
10 return props[valueProp] !== undefined && props[valueProp] !== null;
11}
12//# sourceMappingURL=controlled.js.map
\No newline at end of file