From 290db4d230c062e8180956be84943b0b9e75bf4f Mon Sep 17 00:00:00 2001 From: Albert Yu Date: Fri, 24 Nov 2023 17:47:24 +0800 Subject: [PATCH] Update message and params --- packages/mui-base/src/Select/Select.test.tsx | 4 ++-- .../mui-base/src/utils/useControllableReducer.test.tsx | 4 ++-- packages/mui-base/src/utils/useControllableReducer.ts | 10 +++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/mui-base/src/Select/Select.test.tsx b/packages/mui-base/src/Select/Select.test.tsx index 9c47903f69aedb..3dba6419fcb322 100644 --- a/packages/mui-base/src/Select/Select.test.tsx +++ b/packages/mui-base/src/Select/Select.test.tsx @@ -1365,7 +1365,7 @@ describe('', () => { 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', ); }); }); diff --git a/packages/mui-base/src/utils/useControllableReducer.test.tsx b/packages/mui-base/src/utils/useControllableReducer.test.tsx index c8b2a0b31b6bb8..ba04914d394f9c 100644 --- a/packages/mui-base/src/utils/useControllableReducer.test.tsx +++ b/packages/mui-base/src/utils/useControllableReducer.test.tsx @@ -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', ); }); @@ -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', ); }); }); diff --git a/packages/mui-base/src/utils/useControllableReducer.ts b/packages/mui-base/src/utils/useControllableReducer.ts index 9d46027535b198..544a46e84a066e 100644 --- a/packages/mui-base/src/utils/useControllableReducer.ts +++ b/packages/mui-base/src/utils/useControllableReducer.ts @@ -154,7 +154,7 @@ export function useControllableReducer< stateComparers = EMPTY_OBJECT, onStateChange = NOOP, actionContext, - componentName = 'useControllableReducer', + componentName = '', } = parameters; const controlledPropsRef = React.useRef(controlledProps); @@ -168,7 +168,9 @@ export function useControllableReducer< (controlledProps as Record)[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}`, ); } @@ -177,7 +179,9 @@ export function useControllableReducer< (controlledProps as Record)[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}`, ); } });