diff --git a/.changeset/lazy-guests-call.md b/.changeset/lazy-guests-call.md new file mode 100644 index 000000000..d72388903 --- /dev/null +++ b/.changeset/lazy-guests-call.md @@ -0,0 +1,5 @@ +--- +'@primer/octicons': patch +--- + +Use parameter defaults instead of defaultProps diff --git a/lib/octicons_react/__tests__/tree-shaking.test.js b/lib/octicons_react/__tests__/tree-shaking.test.js index 2db31fdf4..6d0950bbe 100644 --- a/lib/octicons_react/__tests__/tree-shaking.test.js +++ b/lib/octicons_react/__tests__/tree-shaking.test.js @@ -50,5 +50,5 @@ test('tree shaking single export', async () => { }) const bundleSize = Buffer.byteLength(output[0].code.trim()) / 1000 - expect(`${bundleSize}kB`).toMatchInlineSnapshot(`"2.691kB"`) + expect(`${bundleSize}kB`).toMatchInlineSnapshot(`"2.826kB"`) }) diff --git a/lib/octicons_react/src/createIconComponent.js b/lib/octicons_react/src/createIconComponent.js index 75849f0c3..38b13da70 100644 --- a/lib/octicons_react/src/createIconComponent.js +++ b/lib/octicons_react/src/createIconComponent.js @@ -10,7 +10,14 @@ export function createIconComponent(name, defaultClassName, getSVGData) { const svgDataByHeight = getSVGData() const heights = Object.keys(svgDataByHeight) - function Icon({'aria-label': ariaLabel, tabIndex, className, fill = 'currentColor', size, verticalAlign}) { + function Icon({ + 'aria-label': ariaLabel, + tabIndex, + className = defaultClassName, + fill = 'currentColor', + size = 16, + verticalAlign = 'text-bottom' + }) { const height = sizeMap[size] || size const naturalHeight = closestNaturalHeight(heights, height) const naturalWidth = svgDataByHeight[naturalHeight].width @@ -42,11 +49,6 @@ export function createIconComponent(name, defaultClassName, getSVGData) { } Icon.displayName = name - Icon.defaultProps = { - className: defaultClassName, - size: 16, - verticalAlign: 'text-bottom' - } return Icon }