Skip to content

Commit

Permalink
Fix setNativeProps for all elements that inherit from Shape. The native
Browse files Browse the repository at this point in the history
props being set were not passing through extractProps, leading to
various mismatches in the values.
software-mansion#180
software-mansion#326
  • Loading branch information
udfalkso committed May 4, 2017
1 parent bc3659c commit 7b6b040
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 44 deletions.
4 changes: 0 additions & 4 deletions elements/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export default class extends Shape {
r: 0
};

setNativeProps = (...args) => {
this.root.setNativeProps(...args);
};

render() {
let props = this.props;
return <RNSVGCircle
Expand Down
4 changes: 0 additions & 4 deletions elements/Ellipse.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ export default class extends Shape{
ry: 0
};

setNativeProps = (...args) => {
this.root.setNativeProps(...args);
};

render() {
let props = this.props;

Expand Down
4 changes: 0 additions & 4 deletions elements/G.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ export default class extends Shape{

static propTypes = pathProps;

setNativeProps = (...args) => {
this.root.setNativeProps(...args);
};

render() {
let {props} = this;

Expand Down
4 changes: 0 additions & 4 deletions elements/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ export default class extends Shape {
preserveAspectRatio: 'xMidYMid meet'
};

setNativeProps = (...args) => {
this.root.setNativeProps(...args);
};

render() {
let {props} = this;
let modes = props.preserveAspectRatio.trim().split(spacesRegExp);
Expand Down
4 changes: 0 additions & 4 deletions elements/Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ export default class extends Shape {
y2: 0
};

setNativeProps = (...args) => {
this.root.setNativeProps(...args);
};

render() {
let props = this.props;
return <RNSVGLine
Expand Down
4 changes: 0 additions & 4 deletions elements/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ export default class extends Shape {
d: PropTypes.string.isRequired
};

setNativeProps = (...args) => {
this.root.setNativeProps(...args);
};

render() {
let props = this.props;

Expand Down
4 changes: 0 additions & 4 deletions elements/Polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ export default class extends Component{
points: ''
};

setNativeProps = (...args) => {
this.root.getNativeElement().setNativeProps(...args);
};

render() {
let points = this.props.points;
if (Array.isArray(points)) {
Expand Down
4 changes: 0 additions & 4 deletions elements/Rect.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ export default class extends Shape {
ry: 0
};

setNativeProps = (...args) => {
this.root.setNativeProps(...args);
};

render() {
let props = this.props;

Expand Down
13 changes: 13 additions & 0 deletions elements/Shape.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Component} from 'react';
import SvgTouchableMixin from '../lib/SvgTouchableMixin';
import extractProps from '../lib/extract/extractProps';
import _ from 'lodash';

class Shape extends Component {
Expand All @@ -10,6 +11,18 @@ class Shape extends Component {
});
this.state = this.touchableGetInitialState();
}

setNativeProps = (args) => {
var extracted = extractProps(args, this)
var toSet = {}
for(var key in args) {
if (extracted[key]) {
args[key] = extracted[key]
}
}
this.root.setNativeProps(args);
};

}

export default Shape;
4 changes: 0 additions & 4 deletions elements/TSpan.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ export default class extends Shape {
};
};

setNativeProps = (...args) => {
this.root.setNativeProps(...args);
};

render() {
let props = this.props;
return <RNSVGTSpan
Expand Down
4 changes: 0 additions & 4 deletions elements/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export default class extends Shape {
};
};

setNativeProps = (...args) => {
this.root.setNativeProps(...args);
};

render() {
const props = this.props;

Expand Down
4 changes: 0 additions & 4 deletions elements/Use.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ export default class extends Shape {
...pathProps
};

setNativeProps = (...args) => {
this.root.setNativeProps(...args);
};

render() {
const {props} = this;
// match "url(#pattern)"
Expand Down

0 comments on commit 7b6b040

Please sign in to comment.