Files
react-native-mapbox-gl/Annotation.js
T
Bob Fanger 0a9d904358 import PropTypes from ‘prop-types’ and using ViewPropTypes instead of View.propTypes
Fixed errors:
`View.propTypes has been deprecated and will be removed in a future version of ReactNative. Use ViewPropTypes instead.`

`Warning: PropTypes has been moved to a separate package. Accessing React.PropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead.`
2017-07-26 00:35:19 +02:00

55 lines
1.2 KiB
JavaScript

import PropTypes from 'prop-types';
import React from 'react';
import {
View,
ViewPropTypes,
requireNativeComponent,
StyleSheet,
Platform,
NativeModules,
Animated,
findNodeHandle,
} from 'react-native';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
const viewConfig = {
uiViewClassName: 'RCTMapboxAnnotation',
validAttributes: {
coordinate: true,
},
};
const propTypes = {
...ViewPropTypes,
id: PropTypes.string.isRequired,
title: PropTypes.string,
subtitle: PropTypes.string,
coordinate: PropTypes.shape({
latitude: PropTypes.number.isRequired,
longitude: PropTypes.number.isRequired,
}).isRequired,
};
class MapboxAnnotation extends React.Component {
setNativeProps(nativeProps) {
this.marker.setNativeProps(nativeProps);
}
render() {
return (
<RCTMapboxAnnotation
ref={ref => { this.marker = ref; }}
{...this.props}
/>
);
}
}
MapboxAnnotation.propTypes = propTypes;
MapboxAnnotation.viewConfig = viewConfig;
const RCTMapboxAnnotation = requireNativeComponent('RCTMapboxAnnotation', MapboxAnnotation);
module.exports = MapboxAnnotation;