Skip to content

Commit 2f7f989

Browse files
golyaAdam Gólya
andauthored
Replace the deprecated ViewPropTypes (#73)
Using the ViewPropTypes from react-native is deprecated and the react-native-web no longer support it. To be able to use this package with react-native 0.60 on web we need to fix it. Co-authored-by: Adam Gólya <adam@t-shaped.me>
1 parent 539b91b commit 2f7f989

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

dist/components/FontAwesomeIcon.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
2828

2929
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
3030

31-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
31+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3232

3333
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3434

@@ -86,7 +86,7 @@ function FontAwesomeIcon(props) {
8686
var iconLookup = normalizeIconArgs(iconArgs);
8787
var transform = objectWithKey('transform', typeof props.transform === 'string' ? _fontawesomeSvgCore.parse.transform(props.transform) : props.transform);
8888
var mask = objectWithKey('mask', normalizeIconArgs(maskArgs));
89-
var renderedIcon = (0, _fontawesomeSvgCore.icon)(iconLookup, _objectSpread({}, transform, {}, mask));
89+
var renderedIcon = (0, _fontawesomeSvgCore.icon)(iconLookup, _objectSpread(_objectSpread({}, transform), mask));
9090

9191
if (!renderedIcon) {
9292
(0, _logger["default"])("ERROR: icon not found for icon = ", iconArgs);
@@ -146,7 +146,9 @@ FontAwesomeIcon.propTypes = {
146146
color: _propTypes["default"].string,
147147
secondaryColor: _propTypes["default"].string,
148148
secondaryOpacity: _propTypes["default"].number,
149-
style: _propTypes["default"].oneOfType([_propTypes["default"].shape(_objectSpread({}, _reactNative.ViewPropTypes.style)), _propTypes["default"].array]),
149+
style: _propTypes["default"].oneOfType([_propTypes["default"].shape({
150+
style: _propTypes["default"].any
151+
}), _propTypes["default"].array]),
150152
icon: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].array, _propTypes["default"].string]),
151153
mask: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].array, _propTypes["default"].string]),
152154
transform: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].object])

dist/converter.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@ var _reactNativeSvg = require("react-native-svg");
1111

1212
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1313

14-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
14+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
1515

16-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
16+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1717

18-
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
18+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
1919

20-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
20+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
21+
22+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
23+
24+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
2125

2226
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
2327

@@ -47,7 +51,7 @@ function convert(createElement, element) {
4751
var isDuotoneSecondLayer = isDuotone && childIndex === 0;
4852
var fill = isDuotoneSecondLayer ? extraProps.secondaryFill : extraProps.fill;
4953
var fillOpacity = isDuotoneSecondLayer ? extraProps.secondaryOpacity : 1;
50-
return convert(createElement, child, _objectSpread({}, extraProps, {
54+
return convert(createElement, child, _objectSpread(_objectSpread({}, extraProps), {}, {
5155
fill: fill,
5256
fillOpacity: fillOpacity
5357
}));
@@ -80,7 +84,7 @@ function convert(createElement, element) {
8084
}, {
8185
attrs: {}
8286
});
83-
return createElement.apply(void 0, [svgObjectMap[element.tag], _objectSpread({}, mixins.attrs, {}, extraProps)].concat(_toConsumableArray(children)));
87+
return createElement.apply(void 0, [svgObjectMap[element.tag], _objectSpread(_objectSpread({}, mixins.attrs), extraProps)].concat(_toConsumableArray(children)));
8488
}
8589

8690
var _default = convert;

src/components/FontAwesomeIcon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import convert from '../converter'
33
import PropTypes from 'prop-types'
4-
import { Dimensions, ViewPropTypes, StyleSheet } from 'react-native'
4+
import { Dimensions, StyleSheet } from 'react-native'
55
import { icon, parse } from '@fortawesome/fontawesome-svg-core'
66
import log from '../logger'
77

@@ -132,7 +132,7 @@ FontAwesomeIcon.propTypes = {
132132
secondaryOpacity: PropTypes.number,
133133

134134
style: PropTypes.oneOfType([
135-
PropTypes.shape({ ...ViewPropTypes.style }),
135+
PropTypes.shape({ style: PropTypes.any }),
136136
PropTypes.array
137137
]),
138138

0 commit comments

Comments
 (0)