Skip to content

Commit

Permalink
fix: TypeError: props.hasOwnProperty is not a function (#2596)
Browse files Browse the repository at this point in the history
Co-authored-by: zishaofei <zishaofei@bytedance.com>
  • Loading branch information
ShaofeiZi and zishaofei authored Jul 16, 2024
1 parent b2f1218 commit d4afca3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/hooks/src/useControllableValue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ function useControllableValue<T = any>(props: Props = {}, options: Options<T> =
} = options;

const value = props[valuePropName] as T;
const isControlled = props.hasOwnProperty(valuePropName);
const isControlled = Object.prototype.hasOwnProperty.call(props, valuePropName);

const initialValue = useMemo(() => {
if (isControlled) {
return value;
}
if (props.hasOwnProperty(defaultValuePropName)) {
if (Object.prototype.hasOwnProperty.call(props, defaultValuePropName)) {
return props[defaultValuePropName];
}
return defaultValue;
Expand Down

0 comments on commit d4afca3

Please sign in to comment.