Skip to content

Commit 22cd6ea

Browse files
adamalstonGururajj772nikhiltom
authored
fix: normalize renderIcon types (#18683)
* fix: normalize renderIcon types * refactor: normalize renderIcon jsdoc comments --------- Co-authored-by: Gururaj J <89023023+Gururajj77@users.noreply.github.com> Co-authored-by: Nikhil Tomar <63502271+2nikhiltom@users.noreply.github.com>
1 parent fdf8628 commit 22cd6ea

File tree

21 files changed

+72
-106
lines changed

21 files changed

+72
-106
lines changed

packages/react/src/components/Button/Button.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -88,8 +88,7 @@ export interface ButtonBaseProps
8888
rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>['rel'];
8989

9090
/**
91-
* Optional prop to allow overriding the icon rendering.
92-
* Can be a React component class
91+
* A component used to render an icon.
9392
*/
9493
renderIcon?: React.ElementType;
9594

@@ -359,8 +358,7 @@ const Button: ButtonComponent = React.forwardRef(
359358
rel: PropTypes.string,
360359

361360
/**
362-
* Optional prop to allow overriding the icon rendering.
363-
* Can be a React component class
361+
* A component used to render an icon.
364362
*/
365363
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
366364

packages/react/src/components/ChatButton/ChatButton.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2024
2+
* Copyright IBM Corp. 2024, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -45,9 +45,9 @@ export interface ChatButtonProps
4545
* Specify the kind of `ChatButton` you want to create
4646
*/
4747
kind?: ChatButtonKind;
48+
4849
/**
49-
* Optional prop to specify an icon to be rendered.
50-
* Can be a React component class
50+
* A component used to render an icon.
5151
*/
5252
renderIcon?: ComponentType | FunctionComponent;
5353
/**
@@ -142,8 +142,7 @@ ChatButton.propTypes = {
142142
]),
143143

144144
/**
145-
* Optional prop to specify an icon to be rendered.
146-
* Can be a React component class
145+
* A component used to render an icon.
147146
*/
148147
// @ts-expect-error: PropTypes are not expressive enough to cover this case
149148
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),

packages/react/src/components/ContainedList/ContainedListItem/ContainedListItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2022
2+
* Copyright IBM Corp. 2022, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -42,7 +42,7 @@ interface ContainedListItemProps {
4242
onClick?: () => void;
4343

4444
/**
45-
* Provide an optional icon to render in front of the item's content.
45+
* A component used to render an icon.
4646
*/
4747
renderIcon?: ComponentType | FunctionComponent;
4848
}
@@ -130,7 +130,7 @@ ContainedListItem.propTypes = {
130130
onClick: PropTypes.func,
131131

132132
/**
133-
* Provide an optional icon to render in front of the item's content.
133+
* A component used to render an icon.
134134
*/
135135
// @ts-expect-error: PropTypes are not expressive enough to cover this case
136136
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),

packages/react/src/components/DataTable/TableBatchAction.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -24,7 +24,7 @@ export interface TableBatchActionProps
2424
iconDescription?: string;
2525

2626
/**
27-
* Optional function to render your own icon in the underlying button
27+
* A component used to render an icon.
2828
*/
2929
renderIcon?: React.ElementType;
3030
}
@@ -61,7 +61,7 @@ TableBatchAction.propTypes = {
6161
},
6262

6363
/**
64-
* Optional function to render your own icon in the underlying button
64+
* A component used to render an icon.
6565
*/
6666
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
6767
};

packages/react/src/components/DataTable/TableToolbarMenu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -34,7 +34,7 @@ export interface TableToolbarMenuProps
3434
menuOptionsClass?: string;
3535

3636
/**
37-
* Optional prop to allow overriding the default menu icon
37+
* A component used to render an icon.
3838
*/
3939
renderIcon?: any;
4040
}
@@ -90,7 +90,7 @@ TableToolbarMenu.propTypes = {
9090
menuOptionsClass: PropTypes.string,
9191

9292
/**
93-
* Optional prop to allow overriding the default menu icon
93+
* A component used to render an icon.
9494
*/
9595
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
9696
};

packages/react/src/components/Link/Link.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -51,8 +51,7 @@ export interface LinkBaseProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
5151
inline?: boolean;
5252

5353
/**
54-
* @description Optional prop to render an icon next to the link.
55-
* Can be a React component class
54+
* A component used to render an icon.
5655
*/
5756
renderIcon?: ComponentType;
5857

@@ -168,8 +167,7 @@ const Link: LinkComponent = React.forwardRef(
168167
inline: PropTypes.bool,
169168

170169
/**
171-
* Optional prop to render an icon next to the link.
172-
* Can be a React component class
170+
* A component used to render an icon.
173171
*/
174172
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
175173

packages/react/src/components/Menu/MenuItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2023
2+
* Copyright IBM Corp. 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -77,7 +77,7 @@ export interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {
7777
) => void;
7878

7979
/**
80-
* Sets the menu item's icon.
80+
* A component used to render an icon.
8181
*/
8282
renderIcon?: FC;
8383

@@ -320,7 +320,7 @@ MenuItem.propTypes = {
320320
onClick: PropTypes.func,
321321

322322
/**
323-
* Sets the menu item's icon.
323+
* A component used to render an icon.
324324
*/
325325
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
326326
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),

packages/react/src/components/Notification/Notification.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2016, 2023
2+
* Copyright IBM Corp. 2016, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -9,8 +9,6 @@ import PropTypes from 'prop-types';
99
import React, {
1010
type ReactNode,
1111
type MouseEvent,
12-
type ComponentType,
13-
type FunctionComponent,
1412
type ButtonHTMLAttributes,
1513
type HTMLAttributes,
1614
useEffect,
@@ -171,12 +169,9 @@ export interface NotificationButtonProps
171169
notificationType?: 'toast' | 'inline' | 'actionable';
172170

173171
/**
174-
* Optional prop to allow overriding the icon rendering.
175-
* Can be a React component class
172+
* A component used to render an icon.
176173
*/
177-
renderIcon?:
178-
| ComponentType<{ className?: string; name?: string }>
179-
| FunctionComponent<{ className?: string; name?: string }>;
174+
renderIcon?: React.ElementType;
180175
}
181176

182177
export function NotificationButton({
@@ -244,8 +239,7 @@ NotificationButton.propTypes = {
244239
notificationType: PropTypes.oneOf(['toast', 'inline', 'actionable']),
245240

246241
/**
247-
* Optional prop to allow overriding the icon rendering.
248-
* Can be a React component class
242+
* A component used to render an icon.
249243
*/
250244
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
251245

packages/react/src/components/OverflowMenu/OverflowMenu.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
type MenuDirection,
1313
type MenuOffset,
1414
} from '../../internal/FloatingMenu';
15-
import React, { ComponentType } from 'react';
15+
import React from 'react';
1616
import { matches as keyCodeMatches, keys } from '../../internal/keyboard';
1717

1818
import ClickListener from '../../internal/ClickListener';
@@ -89,11 +89,6 @@ export const getMenuOffset: MenuOffset = (
8989
}
9090
};
9191

92-
type IconProps = {
93-
className?: string;
94-
'aria-label'?: string;
95-
};
96-
9792
export interface OverflowMenuProps {
9893
/**
9994
* Specify a label to be read by screen readers on the container node
@@ -189,9 +184,9 @@ export interface OverflowMenuProps {
189184
open?: boolean;
190185

191186
/**
192-
* Function called to override icon rendering.
187+
* A component used to render an icon.
193188
*/
194-
renderIcon?: ComponentType<IconProps>;
189+
renderIcon?: React.ElementType;
195190

196191
/**
197192
* Specify a CSS selector that matches the DOM element that should
@@ -354,7 +349,7 @@ class OverflowMenu extends React.Component<
354349
open: PropTypes.bool,
355350

356351
/**
357-
* Function called to override icon rendering.
352+
* A component used to render an icon.
358353
*/
359354
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
360355

packages/react/src/components/OverflowMenu/next/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright IBM Corp. 2020, 2023
2+
* Copyright IBM Corp. 2020, 2025
33
*
44
* This source code is licensed under the Apache-2.0 license found in the
55
* LICENSE file in the root directory of this source tree.
@@ -69,7 +69,7 @@ interface OverflowMenuProps {
6969
menuAlignment?: 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';
7070

7171
/**
72-
* Optionally provide a custom icon to be rendered on the trigger button.
72+
* A component used to render an icon.
7373
*/
7474
renderIcon?: ComponentType | FunctionComponent;
7575

@@ -276,7 +276,7 @@ OverflowMenu.propTypes = {
276276
]),
277277

278278
/**
279-
* Optionally provide a custom icon to be rendered on the trigger button.
279+
* A component used to render an icon.
280280
*/
281281
// @ts-expect-error: PropTypes are not expressive enough to cover this case
282282
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),

0 commit comments

Comments
 (0)