primer / octicons

A scalable set of icons handcrafted with <3 by GitHub
https://primer.style/foundations/icons
MIT License
8.27k stars 827 forks source link

[Bug] @primer/octicons-react: defaultProps is deprecated #884

Closed bates64 closed 1 year ago

bates64 commented 1 year ago

defaultProps was recently deprecated in React: see https://github.com/facebook/react/pull/16210.

Using any Octicon produces something like the following warning:

Warning: UploadIcon: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.

This is caused by the following code, which needs to be swapped out:

https://github.com/primer/octicons/blob/e05ddd3317c460c1e298cb232bdaa4c2a2d863de/lib/octicons_react/src/createIconComponent.js#L45

Angelfire commented 1 year ago

That's right, I'm getting the same error, I think the solution is easy, just use default parameters in the Icon function, something like:

Icon({'aria-label': ariaLabel, tabIndex, className = defaultClassName, fill = 'currentColor', size = 16, verticalAlign = 'text-bottom'})

Or something like that...

rezrah commented 1 year ago

Hey @nanaian, this should be fixed in the v17.10.1 release. Closing this for now, but feel free to reopen if you have any other questions.