import React, { Component, createRef, MutableRefObject, ReactElement, } from 'react'; import {NativeMethods, requireNativeComponent} from 'react-native'; import {LightLayerStyleProps} from '../utils/VietmapStyles'; import BaseProps from '../types/BaseProps'; import {StyleValue, transformStyle} from '../utils/StyleValue'; import AbstractLayer, {BaseLayerProps} from './AbstractLayer'; export const NATIVE_MODULE_NAME = 'RCTMGLLight'; interface LightProps extends BaseProps { /** * Customizable style attributes */ style?: LightLayerStyleProps; } interface NativeProps extends Omit { reactStyle?: {[key: string]: StyleValue}; } /** * Light represents the light source for extruded geometries */ class Light extends AbstractLayer { lightRef: MutableRefObject< (Component & Readonly) | null >; constructor(props: LightProps & BaseLayerProps) { super(props); this.lightRef = createRef< (Component & Readonly) | null >(); } setNativeProps(props: LightProps): void { if (this.lightRef.current && props.style) { const nativeProps = { ...props, reactStyle: transformStyle(props.style), }; this.lightRef.current.setNativeProps(nativeProps); } } render(): ReactElement { return ( ); } } const RCTMGLLight = requireNativeComponent(NATIVE_MODULE_NAME); export default Light;