Skip to content

Commit 503bafb

Browse files
authored
Use parameter defaults instead of defaultProps (#882)
* Use parameter defaults instead of defaultProps * changeset * lint * update bundle size in test * update bundle size in test
1 parent 8a039a7 commit 503bafb

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

.changeset/lazy-guests-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/octicons': patch
3+
---
4+
5+
Use parameter defaults instead of defaultProps

lib/octicons_react/__tests__/tree-shaking.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ test('tree shaking single export', async () => {
5050
})
5151

5252
const bundleSize = Buffer.byteLength(output[0].code.trim()) / 1000
53-
expect(`${bundleSize}kB`).toMatchInlineSnapshot(`"2.691kB"`)
53+
expect(`${bundleSize}kB`).toMatchInlineSnapshot(`"2.826kB"`)
5454
})

lib/octicons_react/src/createIconComponent.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ export function createIconComponent(name, defaultClassName, getSVGData) {
1010
const svgDataByHeight = getSVGData()
1111
const heights = Object.keys(svgDataByHeight)
1212

13-
function Icon({'aria-label': ariaLabel, tabIndex, className, fill = 'currentColor', size, verticalAlign}) {
13+
function Icon({
14+
'aria-label': ariaLabel,
15+
tabIndex,
16+
className = defaultClassName,
17+
fill = 'currentColor',
18+
size = 16,
19+
verticalAlign = 'text-bottom'
20+
}) {
1421
const height = sizeMap[size] || size
1522
const naturalHeight = closestNaturalHeight(heights, height)
1623
const naturalWidth = svgDataByHeight[naturalHeight].width
@@ -42,11 +49,6 @@ export function createIconComponent(name, defaultClassName, getSVGData) {
4249
}
4350

4451
Icon.displayName = name
45-
Icon.defaultProps = {
46-
className: defaultClassName,
47-
size: 16,
48-
verticalAlign: 'text-bottom'
49-
}
5052

5153
return Icon
5254
}

0 commit comments

Comments
 (0)