UNPKG

847 BSource Map (JSON)View Raw
1{"version":3,"file":"controlled.js","sourceRoot":"../src/","sources":["controlled.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,SAAgB,YAAY,CAAI,KAAQ,EAAE,SAAkB;IAC1D,+FAA+F;IAC/F,uEAAuE;IACvE,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;AACrE,CAAC;AAJD,oCAIC","sourcesContent":["/**\n * Determines whether a component is controlled.\n * @param props - Component props\n * @param valueProp - Prop containing the controlled value\n * @returns true if controlled, false if uncontrolled\n */\nexport function isControlled<P>(props: P, valueProp: keyof P): boolean {\n // React's built-in <input> considers a prop to be provided if its value is non-null/undefined.\n // Mirror that behavior here (rather than checking for just undefined).\n return props[valueProp] !== undefined && props[valueProp] !== null;\n}\n"]}
\No newline at end of file