UNPKG

react-native-anavi

Version:

react native amap navigation component, Android + iOS

52 lines (40 loc) 1.31 kB
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; } /** * Base component, contains some utils */ import { PureComponent } from 'react'; import { findNodeHandle, UIManager, Platform } from 'react-native'; /** * @ignore */ export default class Component extends PureComponent { constructor(...args) { super(...args); _defineProperty(this, "props", void 0); _defineProperty(this, "nativeComponent", void 0); _defineProperty(this, "handlers", events => events.reduce((handlers, name) => { const handler = this.props[name]; if (handler) { if (Platform.OS === 'android') { name = name.replace(/^on/, 'onAMap'); } handlers[name] = event => handler(event.nativeEvent); } return handlers; }, {})); } /** * Call native method */ call(name, params) { const handle = findNodeHandle(this); if (handle) { const command = UIManager.getViewManagerConfig(this.nativeComponent).Commands[name]; UIManager.dispatchViewManagerCommand(handle, command, params); } } /** * Generate event handlers */ } //# sourceMappingURL=component.js.map