Skip to content

Commit

Permalink
Make AbstractSource _nativeRef compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
mfazekas committed Jun 9, 2020
1 parent 0bbaa48 commit 6b70715
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ node_modules
package-lock.json
/example/package-lock.json

# Expo
.expo

# OS X
.DS_Store

Expand Down
6 changes: 3 additions & 3 deletions __tests__/utils/animated/AnimatedCoordinatesArray.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('AnimatedShapeSource', () => {
/>,
);
const setNativeProps = jest.fn();
shapeSourceRef._component.refs.nativeSource.setNativeProps = setNativeProps;
shapeSourceRef._component._nativeRef.setNativeProps = setNativeProps;

coordinates
.timing({
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('AnimatedShapeSource', () => {
/>,
);
const setNativeProps = jest.fn();
shapeSourceRef._component.refs.nativeSource.setNativeProps = setNativeProps;
shapeSourceRef._component._nativeRef.setNativeProps = setNativeProps;

coordinates
.timing({
Expand Down Expand Up @@ -147,7 +147,7 @@ describe('AnimatedShapeSource', () => {
/>,
);
const setNativeProps = jest.fn();
shapeSourceRef._component.refs.nativeSource.setNativeProps = setNativeProps;
shapeSourceRef._component._nativeRef.setNativeProps = setNativeProps;

coordinates
.timing({
Expand Down
8 changes: 6 additions & 2 deletions javascript/components/AbstractSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import React from 'react';

class AbstractSource extends React.PureComponent {
setNativeProps(props) {
if (this.refs.nativeSource) {
this.refs.nativeSource.setNativeProps(props);
if (this._nativeRef) {
this._nativeRef.setNativeProps(props);
} else {
if (this.refs.nativeSource) {
this.refs.nativeSource.setNativeProps(props);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion javascript/components/ShapeSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class ShapeSource extends NativeBridgeComponent(AbstractSource) {
};

return (
<RCTMGLShapeSource ref="nativeSource" {...props}>
<RCTMGLShapeSource {...props}>
{cloneReactChildrenWithProps(this.props.children, {
sourceID: this.props.id,
})}
Expand Down

0 comments on commit 6b70715

Please sign in to comment.