UNPKG

@vis.gl/react-google-maps

Version:

React components and hooks for the Google Maps JavaScript API

24 lines (21 loc) 489 B
import {useEffect} from 'react'; /** * Internally used to copy values from props into API-Objects * whenever they change. * * @example * usePropBinding(marker, 'position', position); * * @internal */ export function usePropBinding<T extends object, K extends keyof T>( object: T | null, prop: K, value: T[K] ) { useEffect(() => { if (!object) return; // eslint-disable-next-line react-hooks/immutability object[prop] = value; }, [object, prop, value]); }