diff --git a/packages/mui-base/src/useDropdown/useDropdown.ts b/packages/mui-base/src/useDropdown/useDropdown.ts index 802018f91fec62..a7e4a875ce120e 100644 --- a/packages/mui-base/src/useDropdown/useDropdown.ts +++ b/packages/mui-base/src/useDropdown/useDropdown.ts @@ -43,6 +43,7 @@ export function useDropdown(parameters: UseDropdownParameters = {}) { initialState: defaultOpen ? { open: true } : { open: false }, onStateChange: handleStateChange, reducer: dropdownReducer, + name: 'useDropdown', }); React.useEffect(() => { diff --git a/packages/mui-base/src/useList/useList.ts b/packages/mui-base/src/useList/useList.ts index fca8c10f364291..789d73487049bc 100644 --- a/packages/mui-base/src/useList/useList.ts +++ b/packages/mui-base/src/useList/useList.ts @@ -91,6 +91,7 @@ function useList< reducerActionContext = EMPTY_OBJECT as CustomActionContext, selectionMode = 'single', stateReducer: externalReducer, + name = 'useList', } = params; if (process.env.NODE_ENV !== 'production') { @@ -222,6 +223,7 @@ function useList< controlledProps, stateComparers, onStateChange: handleStateChange, + name, }); const { highlightedValue, selectedValues } = state; diff --git a/packages/mui-base/src/useList/useList.types.ts b/packages/mui-base/src/useList/useList.types.ts index b6df0f4058ead2..8b205e931517e2 100644 --- a/packages/mui-base/src/useList/useList.types.ts +++ b/packages/mui-base/src/useList/useList.types.ts @@ -215,6 +215,10 @@ export interface UseListParameters< ListActionContext & CustomActionContext >, ) => State; + /** + * The name of the hook or component + */ + name?: string; } export interface ListItemState { diff --git a/packages/mui-base/src/utils/useControllableReducer.test.tsx b/packages/mui-base/src/utils/useControllableReducer.test.tsx index 76f0fe30f0241d..10f631507d5070 100644 --- a/packages/mui-base/src/utils/useControllableReducer.test.tsx +++ b/packages/mui-base/src/utils/useControllableReducer.test.tsx @@ -49,6 +49,7 @@ describe('useControllableReducer', () => { reducer, controlledProps: {}, initialState: { make: 'Mazda', model: '3', productionYear: 2022 }, + name: 'TestReducer', }; function TestComponent() { @@ -73,6 +74,7 @@ describe('useControllableReducer', () => { reducer: (state) => state, controlledProps: {}, initialState: { make: 'Mazda', model: '3', productionYear: 2022 }, + name: 'TestReducer', }; function TestComponent() { @@ -109,6 +111,7 @@ describe('useControllableReducer', () => { const reducerParameters: ControllableReducerParameters = { reducer, initialState: { make: 'Mazda', model: '3', productionYear: 2022 }, + name: 'TestReducer', }; function TestComponent(props: { make: string }) { @@ -136,6 +139,7 @@ describe('useControllableReducer', () => { const reducerParameters: ControllableReducerParameters = { reducer: (state) => state, initialState: { make: 'Mazda', model: '3', productionYear: 2022 }, + name: 'TestReducer', }; function TestComponent(props: { make: string }) { @@ -166,6 +170,7 @@ describe('useControllableReducer', () => { const reducerParameters: ControllableReducerParameters = { reducer: (state) => state, initialState: { make: 'Mazda', model: '3', productionYear: 2022 }, + name: 'TestReducer', }; function TestComponent(props: { make?: string }) { @@ -227,6 +232,7 @@ describe('useControllableReducer', () => { a.every((v, i) => v === b[i]), }, onStateChange: onStateChangeSpy, + name: 'TestReducer', }; function TestComponent() { @@ -267,6 +273,7 @@ describe('useControllableReducer', () => { controlledProps: {}, initialState: { make: 'Mazda', model: '3', productionYear: 2022 }, onStateChange: handleChange, + name: 'TestReducer', }; function TestComponent() { @@ -318,6 +325,7 @@ describe('useControllableReducer', () => { controlledProps: {}, initialState: { make: 'Mazda', model: '3', productionYear: 2022 }, actionContext: { overrideProductionYear: 2016 }, + name: 'TestReducer', }; function TestComponent() { diff --git a/packages/mui-base/src/utils/useControllableReducer.types.ts b/packages/mui-base/src/utils/useControllableReducer.types.ts index c4769af6c32ae9..6dc1772d867b73 100644 --- a/packages/mui-base/src/utils/useControllableReducer.types.ts +++ b/packages/mui-base/src/utils/useControllableReducer.types.ts @@ -52,9 +52,13 @@ export interface ControllableReducerParameters< */ onStateChange?: StateChangeCallback; /** - * Additional properties that will be added to the action. + * The name of the hook or component */ actionContext?: ActionContext; + /** + * Additional properties that will be added to the action. + */ + name: string; } /*