Skip to content

Commit

Permalink
fix: TypeError: props.hasOwnProperty is not a function
Browse files Browse the repository at this point in the history
  • Loading branch information
zishaofei committed Jul 12, 2024
1 parent b2f1218 commit a8e4f87
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 a8e4f87

Please sign in to comment.