Skip to content

Commit

Permalink
Update message and params
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert committed Nov 25, 2023
1 parent dfb95cd commit 290db4d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/mui-base/src/Select/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ describe('<Select />', () => {
expect(() => {
setProps({ value: undefined });
}).toErrorDev(
'MUI: A component: useSelect is changing a controlled prop to be uncontrolled: selectedValues',
'useControllableReducer: The useSelect component is changing a controlled prop to be uncontrolled: selectedValues',
);
});

Expand All @@ -1380,7 +1380,7 @@ describe('<Select />', () => {
expect(() => {
setProps({ value: 1 });
}).toErrorDev(
'MUI: A component: useSelect is changing an uncontrolled prop to be controlled: selectedValues',
'useControllableReducer: The useSelect component is changing an uncontrolled prop to be controlled: selectedValues',
);
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-base/src/utils/useControllableReducer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ describe('useControllableReducer', () => {
expect(() => {
setProps({ make: undefined });
}).to.toErrorDev(
'MUI: A component: useControllableReducer is changing a controlled prop to be uncontrolled: make',
'useControllableReducer: A component is changing a controlled prop to be uncontrolled: make',
);
});

Expand Down Expand Up @@ -188,7 +188,7 @@ describe('useControllableReducer', () => {
expect(() => {
setProps({ make: 'Tesla' });
}).to.toErrorDev(
'MUI: A component: useControllableReducer is changing an uncontrolled prop to be controlled: make',
'useControllableReducer: A component is changing an uncontrolled prop to be controlled: make',
);
});
});
Expand Down
10 changes: 7 additions & 3 deletions packages/mui-base/src/utils/useControllableReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export function useControllableReducer<
stateComparers = EMPTY_OBJECT,
onStateChange = NOOP,
actionContext,
componentName = 'useControllableReducer',
componentName = '',
} = parameters;

const controlledPropsRef = React.useRef(controlledProps);
Expand All @@ -168,7 +168,9 @@ export function useControllableReducer<
(controlledProps as Record<string, unknown>)[key] === undefined
) {
console.error(
`MUI: A component: ${componentName} is changing a controlled prop to be uncontrolled: ${key}`,
`useControllableReducer: ${
componentName ? `The ${componentName} component` : 'A component'
} is changing a controlled prop to be uncontrolled: ${key}`,
);
}

Expand All @@ -177,7 +179,9 @@ export function useControllableReducer<
(controlledProps as Record<string, unknown>)[key] !== undefined
) {
console.error(
`MUI: A component: ${componentName} is changing an uncontrolled prop to be controlled: ${key}`,
`useControllableReducer: ${
componentName ? `The ${componentName} component` : 'A component'
} is changing an uncontrolled prop to be controlled: ${key}`,
);
}
});
Expand Down

0 comments on commit 290db4d

Please sign in to comment.