mirror of
https://github.com/sstent/aicyclingcoach-go.git
synced 2026-01-27 17:42:23 +00:00
sync
This commit is contained in:
34
node_modules/@react-leaflet/core/lib/element.js
generated
vendored
Normal file
34
node_modules/@react-leaflet/core/lib/element.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
export function createElementObject(instance, context, container) {
|
||||
return Object.freeze({
|
||||
instance,
|
||||
context,
|
||||
container
|
||||
});
|
||||
}
|
||||
export function createElementHook(createElement, updateElement) {
|
||||
if (updateElement == null) {
|
||||
return function useImmutableLeafletElement(props, context) {
|
||||
const elementRef = useRef();
|
||||
if (!elementRef.current) elementRef.current = createElement(props, context);
|
||||
return elementRef;
|
||||
};
|
||||
}
|
||||
return function useMutableLeafletElement(props, context) {
|
||||
const elementRef = useRef();
|
||||
if (!elementRef.current) elementRef.current = createElement(props, context);
|
||||
const propsRef = useRef(props);
|
||||
const { instance } = elementRef.current;
|
||||
useEffect(function updateElementProps() {
|
||||
if (propsRef.current !== props) {
|
||||
updateElement(instance, props, propsRef.current);
|
||||
propsRef.current = props;
|
||||
}
|
||||
}, [
|
||||
instance,
|
||||
props,
|
||||
context
|
||||
]);
|
||||
return elementRef;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user