diff --git a/CHANGELOG.md b/CHANGELOG.md index 332e7d9..fc8c6fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p --- +## [0.2.1](https://github.com/FortAwesome/react-fontawesome/releases/tag/0.2.1) - 2024-05-16 + +### Changed + +- Remove defaultProps to be compatible with React 19 + ## [0.2.0](https://github.com/FortAwesome/react-fontawesome/releases/tag/0.2.0) - 2022-06-29 ### Added diff --git a/README.md b/README.md index 49eec73..af3bd5d 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ being awesome contributors to this project. **We'd like to take a moment to reco | Tiago Sousa | [@TiagoPortfolio](https://github.com/TiagoPortfolio) | | Alexey Victorov | [@AliMamed](https://github.com/AliMamed) | | Calum Smith | [@cpmsmith](https://github.com/cpmsmith) | +| squiaios | [@squiaios](https://github.com/squiaios) | | Font Awesome Team | [@FortAwesome](https://github.com/orgs/FortAwesome/people)| If we've missed someone (which is quite likely) submit a Pull Request to us and we'll get it resolved. diff --git a/index.es.js b/index.es.js index fb14f93..24def67 100644 --- a/index.es.js +++ b/index.es.js @@ -329,17 +329,47 @@ function objectWithKey(key, value) { return Array.isArray(value) && value.length > 0 || !Array.isArray(value) && value ? _defineProperty({}, key, value) : {}; } +var defaultProps = { + border: false, + className: '', + mask: null, + maskId: null, + fixedWidth: false, + inverse: false, + flip: false, + icon: null, + listItem: false, + pull: null, + pulse: false, + rotation: null, + size: null, + spin: false, + spinPulse: false, + spinReverse: false, + beat: false, + fade: false, + beatFade: false, + bounce: false, + shake: false, + symbol: false, + title: '', + titleId: null, + transform: null, + swapOpacity: false +}; var FontAwesomeIcon = /*#__PURE__*/React.forwardRef(function (props, ref) { - var iconArgs = props.icon, - maskArgs = props.mask, - symbol = props.symbol, - className = props.className, - title = props.title, - titleId = props.titleId, - maskId = props.maskId; + var allProps = _objectSpread2(_objectSpread2({}, defaultProps), props); + + var iconArgs = allProps.icon, + maskArgs = allProps.mask, + symbol = allProps.symbol, + className = allProps.className, + title = allProps.title, + titleId = allProps.titleId, + maskId = allProps.maskId; var iconLookup = normalizeIconArgs(iconArgs); - var classes = objectWithKey('classes', [].concat(_toConsumableArray(classList(props)), _toConsumableArray(className.split(' ')))); - var transform = objectWithKey('transform', typeof props.transform === 'string' ? parse.transform(props.transform) : props.transform); + var classes = objectWithKey('classes', [].concat(_toConsumableArray(classList(allProps)), _toConsumableArray(className.split(' ')))); + var transform = objectWithKey('transform', typeof allProps.transform === 'string' ? parse.transform(allProps.transform) : allProps.transform); var mask = objectWithKey('mask', normalizeIconArgs(maskArgs)); var renderedIcon = icon(iconLookup, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, classes), transform), mask), {}, { symbol: symbol, @@ -357,10 +387,10 @@ var FontAwesomeIcon = /*#__PURE__*/React.forwardRef(function (props, ref) { var extraProps = { ref: ref }; - Object.keys(props).forEach(function (key) { + Object.keys(allProps).forEach(function (key) { // eslint-disable-next-line no-prototype-builtins - if (!FontAwesomeIcon.defaultProps.hasOwnProperty(key)) { - extraProps[key] = props[key]; + if (!defaultProps.hasOwnProperty(key)) { + extraProps[key] = allProps[key]; } }); return convertCurry(abstract[0], extraProps); @@ -395,34 +425,6 @@ FontAwesomeIcon.propTypes = { transform: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), swapOpacity: PropTypes.bool }; -FontAwesomeIcon.defaultProps = { - border: false, - className: '', - mask: null, - maskId: null, - fixedWidth: false, - inverse: false, - flip: false, - icon: null, - listItem: false, - pull: null, - pulse: false, - rotation: null, - size: null, - spin: false, - spinPulse: false, - spinReverse: false, - beat: false, - fade: false, - beatFade: false, - bounce: false, - shake: false, - symbol: false, - title: '', - titleId: null, - transform: null, - swapOpacity: false -}; var convertCurry = convert.bind(null, React.createElement); export { FontAwesomeIcon }; diff --git a/index.js b/index.js index 3a19669..7129ae8 100644 --- a/index.js +++ b/index.js @@ -336,17 +336,47 @@ return Array.isArray(value) && value.length > 0 || !Array.isArray(value) && value ? _defineProperty({}, key, value) : {}; } + var defaultProps = { + border: false, + className: '', + mask: null, + maskId: null, + fixedWidth: false, + inverse: false, + flip: false, + icon: null, + listItem: false, + pull: null, + pulse: false, + rotation: null, + size: null, + spin: false, + spinPulse: false, + spinReverse: false, + beat: false, + fade: false, + beatFade: false, + bounce: false, + shake: false, + symbol: false, + title: '', + titleId: null, + transform: null, + swapOpacity: false + }; var FontAwesomeIcon = /*#__PURE__*/React__default["default"].forwardRef(function (props, ref) { - var iconArgs = props.icon, - maskArgs = props.mask, - symbol = props.symbol, - className = props.className, - title = props.title, - titleId = props.titleId, - maskId = props.maskId; + var allProps = _objectSpread2(_objectSpread2({}, defaultProps), props); + + var iconArgs = allProps.icon, + maskArgs = allProps.mask, + symbol = allProps.symbol, + className = allProps.className, + title = allProps.title, + titleId = allProps.titleId, + maskId = allProps.maskId; var iconLookup = normalizeIconArgs(iconArgs); - var classes = objectWithKey('classes', [].concat(_toConsumableArray(classList(props)), _toConsumableArray(className.split(' ')))); - var transform = objectWithKey('transform', typeof props.transform === 'string' ? fontawesomeSvgCore.parse.transform(props.transform) : props.transform); + var classes = objectWithKey('classes', [].concat(_toConsumableArray(classList(allProps)), _toConsumableArray(className.split(' ')))); + var transform = objectWithKey('transform', typeof allProps.transform === 'string' ? fontawesomeSvgCore.parse.transform(allProps.transform) : allProps.transform); var mask = objectWithKey('mask', normalizeIconArgs(maskArgs)); var renderedIcon = fontawesomeSvgCore.icon(iconLookup, _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, classes), transform), mask), {}, { symbol: symbol, @@ -364,10 +394,10 @@ var extraProps = { ref: ref }; - Object.keys(props).forEach(function (key) { + Object.keys(allProps).forEach(function (key) { // eslint-disable-next-line no-prototype-builtins - if (!FontAwesomeIcon.defaultProps.hasOwnProperty(key)) { - extraProps[key] = props[key]; + if (!defaultProps.hasOwnProperty(key)) { + extraProps[key] = allProps[key]; } }); return convertCurry(abstract[0], extraProps); @@ -402,34 +432,6 @@ transform: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].object]), swapOpacity: PropTypes__default["default"].bool }; - FontAwesomeIcon.defaultProps = { - border: false, - className: '', - mask: null, - maskId: null, - fixedWidth: false, - inverse: false, - flip: false, - icon: null, - listItem: false, - pull: null, - pulse: false, - rotation: null, - size: null, - spin: false, - spinPulse: false, - spinReverse: false, - beat: false, - fade: false, - beatFade: false, - bounce: false, - shake: false, - symbol: false, - title: '', - titleId: null, - transform: null, - swapOpacity: false - }; var convertCurry = convert.bind(null, React__default["default"].createElement); exports.FontAwesomeIcon = FontAwesomeIcon; diff --git a/package.json b/package.json index 1139564..59416d3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@fortawesome/react-fontawesome", "description": "Official React component for Font Awesome", - "version": "0.2.0", + "version": "0.2.1", "main": "index.js", "module": "index.es.js", "jsnext:main": "index.es.js", @@ -27,7 +27,8 @@ "Proudust ", "Tiago Sousa ", "Alexey Victorov ", - "Calum Smith " + "Calum Smith ", + "squiaios " ], "license": "MIT", "scripts": {