mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-05-31 05:51:47 +00:00
Simplify Svg element render method and pickNotNil
This commit is contained in:
+6
-3
@@ -97,6 +97,11 @@ export default class Svg extends Shape {
|
||||
flex: 0,
|
||||
} : null;
|
||||
|
||||
const o = +opacity;
|
||||
const opacityStyle = !isNaN(o) ? {
|
||||
opacity: o,
|
||||
} : null;
|
||||
|
||||
return (
|
||||
<NativeSvgView
|
||||
{...props}
|
||||
@@ -108,9 +113,7 @@ export default class Svg extends Shape {
|
||||
style={[
|
||||
styles.svg,
|
||||
style,
|
||||
!isNaN(+opacity) && {
|
||||
opacity: +opacity,
|
||||
},
|
||||
opacityStyle,
|
||||
dimensions,
|
||||
]}
|
||||
{...extractResponder(props, this)}
|
||||
|
||||
+6
-8
@@ -1,13 +1,11 @@
|
||||
export function pickNotNil(object) {
|
||||
const result = {};
|
||||
const keys = Object.keys(object);
|
||||
const l = keys.length;
|
||||
for (let i = 0; i < l; i++) {
|
||||
const key = keys[i];
|
||||
const value = object[key];
|
||||
// eslint-disable-next-line eqeqeq
|
||||
if (value != null) {
|
||||
result[key] = value;
|
||||
for (const key in object) {
|
||||
if (object.hasOwnProperty(key)) {
|
||||
const value = object[key];
|
||||
if (value !== undefined && value !== null) {
|
||||
result[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user