react-bkoi-gl 1.0.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +163 -18
- package/dist/components/attribution-control.d.ts +4 -6
- package/dist/components/attribution-control.js +6 -5
- package/dist/components/attribution-control.js.map +1 -1
- package/dist/components/fullscreen-control.d.ts +4 -6
- package/dist/components/fullscreen-control.js +4 -4
- package/dist/components/fullscreen-control.js.map +1 -1
- package/dist/components/geolocate-control.d.ts +10 -26
- package/dist/components/geolocate-control.js +11 -11
- package/dist/components/geolocate-control.js.map +1 -1
- package/dist/components/layer.d.ts +7 -6
- package/dist/components/layer.js +8 -9
- package/dist/components/layer.js.map +1 -1
- package/dist/components/logo-control.d.ts +9 -0
- package/dist/components/logo-control.js +28 -0
- package/dist/components/logo-control.js.map +1 -0
- package/dist/components/map.d.ts +20 -16
- package/dist/components/map.js +38 -32
- package/dist/components/map.js.map +1 -1
- package/dist/components/marker.d.ts +10 -33
- package/dist/components/marker.js +22 -15
- package/dist/components/marker.js.map +1 -1
- package/dist/components/navigation-control.d.ts +4 -6
- package/dist/components/navigation-control.js +4 -4
- package/dist/components/navigation-control.js.map +1 -1
- package/dist/components/popup.d.ts +7 -25
- package/dist/components/popup.js +17 -28
- package/dist/components/popup.js.map +1 -1
- package/dist/components/scale-control.d.ts +4 -6
- package/dist/components/scale-control.js +4 -4
- package/dist/components/scale-control.js.map +1 -1
- package/dist/components/source.d.ts +3 -4
- package/dist/components/source.js +20 -22
- package/dist/components/source.js.map +1 -1
- package/dist/components/terrain-control.d.ts +10 -0
- package/dist/components/terrain-control.js +19 -0
- package/dist/components/terrain-control.js.map +1 -0
- package/dist/components/use-control.d.ts +6 -6
- package/dist/components/use-control.js +4 -5
- package/dist/components/use-control.js.map +1 -1
- package/dist/components/use-map.d.ts +8 -9
- package/dist/components/use-map.js +5 -5
- package/dist/components/use-map.js.map +1 -1
- package/dist/exports-maplibre-gl.d.ts +33 -0
- package/dist/exports-maplibre-gl.js +21 -0
- package/dist/exports-maplibre-gl.js.map +1 -0
- package/dist/index.cjs +590 -681
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/{mapbox → maplibre}/create-ref.d.ts +6 -6
- package/dist/maplibre/create-ref.js +30 -0
- package/dist/maplibre/create-ref.js.map +1 -0
- package/dist/maplibre/maplibre.d.ts +81 -0
- package/dist/maplibre/maplibre.js +387 -0
- package/dist/maplibre/maplibre.js.map +1 -0
- package/dist/styles/index.d.ts +4 -0
- package/dist/styles/react-bkoi-gl.css +1 -1
- package/dist/styles.d.js +2 -0
- package/dist/styles.d.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/common.d.ts +2 -60
- package/dist/types/common.js.map +1 -1
- package/dist/types/events.d.ts +64 -23
- package/dist/types/events.js.map +1 -1
- package/dist/types/internal.d.ts +14 -0
- package/dist/types/internal.js +2 -0
- package/dist/types/internal.js.map +1 -0
- package/dist/types/lib.d.ts +16 -200
- package/dist/types/lib.js.map +1 -1
- package/dist/types/style-spec.d.ts +1 -0
- package/dist/types/style-spec.js +2 -0
- package/dist/types/style-spec.js.map +1 -0
- package/dist/utils/apply-react-style.d.ts +1 -1
- package/dist/utils/apply-react-style.js.map +1 -1
- package/dist/utils/compare-class-names.d.ts +2 -0
- package/dist/utils/compare-class-names.js +23 -0
- package/dist/utils/compare-class-names.js.map +1 -0
- package/dist/utils/deep-equal.d.ts +1 -1
- package/dist/utils/deep-equal.js +1 -1
- package/dist/utils/deep-equal.js.map +1 -1
- package/dist/utils/set-globals.d.ts +6 -8
- package/dist/utils/set-globals.js +22 -10
- package/dist/utils/set-globals.js.map +1 -1
- package/dist/utils/style-utils.d.ts +3 -2
- package/dist/utils/style-utils.js +4 -4
- package/dist/utils/style-utils.js.map +1 -1
- package/dist/utils/transform.d.ts +11 -19
- package/dist/utils/transform.js +13 -36
- package/dist/utils/transform.js.map +1 -1
- package/dist/utils/use-isomorphic-layout-effect.d.ts +1 -1
- package/dist/utils/use-isomorphic-layout-effect.js +2 -2
- package/dist/utils/use-isomorphic-layout-effect.js.map +1 -1
- package/package.json +42 -26
- package/src/components/attribution-control.ts +40 -16
- package/src/components/fullscreen-control.ts +40 -0
- package/src/components/geolocate-control.ts +45 -39
- package/src/components/layer.ts +37 -29
- package/src/components/logo-control.ts +44 -0
- package/src/components/map.tsx +86 -75
- package/src/components/marker.ts +141 -123
- package/src/components/navigation-control.ts +11 -12
- package/src/components/popup.ts +94 -97
- package/src/components/scale-control.ts +12 -14
- package/src/components/source.ts +58 -57
- package/src/components/terrain-control.ts +29 -0
- package/src/components/use-control.ts +21 -17
- package/src/components/use-map.tsx +26 -24
- package/src/exports-maplibre-gl.ts +37 -0
- package/src/index.ts +3 -2
- package/src/maplibre/create-ref.ts +70 -0
- package/src/maplibre/maplibre.ts +624 -0
- package/src/styles.d.ts +4 -0
- package/src/types/common.ts +12 -72
- package/src/types/events.ts +102 -42
- package/src/types/internal.ts +26 -0
- package/src/types/lib.ts +65 -260
- package/src/types/style-spec.ts +34 -0
- package/src/utils/apply-react-style.ts +7 -3
- package/src/utils/compare-class-names.ts +29 -0
- package/src/utils/deep-equal.ts +2 -2
- package/src/utils/set-globals.ts +22 -28
- package/src/utils/style-utils.ts +18 -9
- package/src/utils/transform.ts +32 -60
- package/src/utils/use-isomorphic-layout-effect.ts +3 -2
- package/bkoi-gl/package.json +0 -6
- package/dist/exports-bkoi-gl.cjs +0 -1512
- package/dist/exports-bkoi-gl.d.ts +0 -89
- package/dist/exports-bkoi-gl.js +0 -36
- package/dist/exports-bkoi-gl.js.map +0 -1
- package/dist/exports-mapbox.d.ts +0 -139
- package/dist/exports-mapbox.js +0 -36
- package/dist/exports-mapbox.js.map +0 -1
- package/dist/mapbox/create-ref.js +0 -64
- package/dist/mapbox/create-ref.js.map +0 -1
- package/dist/mapbox/mapbox.d.ts +0 -81
- package/dist/mapbox/mapbox.js +0 -476
- package/dist/mapbox/mapbox.js.map +0 -1
- package/dist/types/events-bkoi-gl.d.ts +0 -49
- package/dist/types/events-bkoi-gl.js +0 -2
- package/dist/types/events-bkoi-gl.js.map +0 -1
- package/dist/types/events-mapbox.d.ts +0 -49
- package/dist/types/events-mapbox.js +0 -2
- package/dist/types/events-mapbox.js.map +0 -1
- package/dist/types/index.d.ts +0 -70
- package/dist/types/index.js +0 -5
- package/dist/types/index.js.map +0 -1
- package/dist/types/public.d.ts +0 -2
- package/dist/types/public.js +0 -2
- package/dist/types/public.js.map +0 -1
- package/dist/types/style-spec-bkoi-gl.d.ts +0 -9
- package/dist/types/style-spec-bkoi-gl.js +0 -2
- package/dist/types/style-spec-bkoi-gl.js.map +0 -1
- package/dist/types/style-spec-mapbox.d.ts +0 -7
- package/dist/types/style-spec-mapbox.js +0 -2
- package/dist/types/style-spec-mapbox.js.map +0 -1
- package/src/components/fullscreen-control.tsx +0 -37
- package/src/exports-bkoi-gl.ts +0 -156
- package/src/exports-mapbox.ts +0 -159
- package/src/mapbox/create-ref.ts +0 -118
- package/src/mapbox/mapbox.ts +0 -742
- package/src/types/events-bkoi-gl.ts +0 -78
- package/src/types/events-mapbox.ts +0 -76
- package/src/types/index.ts +0 -93
- package/src/types/public.ts +0 -9
- package/src/types/style-spec-bkoi-gl.ts +0 -81
- package/src/types/style-spec-mapbox.ts +0 -80
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Compare two classNames string and return the difference */
|
|
2
|
+
export function compareClassNames(
|
|
3
|
+
prevClassName: string | undefined,
|
|
4
|
+
nextClassName: string | undefined,
|
|
5
|
+
): string[] | null {
|
|
6
|
+
if (prevClassName === nextClassName) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const prevClassList = getClassList(prevClassName);
|
|
11
|
+
const nextClassList = getClassList(nextClassName);
|
|
12
|
+
const diff: string[] = [];
|
|
13
|
+
|
|
14
|
+
for (const c of nextClassList) {
|
|
15
|
+
if (!prevClassList.has(c)) {
|
|
16
|
+
diff.push(c);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
for (const c of prevClassList) {
|
|
20
|
+
if (!nextClassList.has(c)) {
|
|
21
|
+
diff.push(c);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return diff.length === 0 ? null : diff;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getClassList(className: string | undefined) {
|
|
28
|
+
return new Set(className ? className.trim().split(/\s+/) : []);
|
|
29
|
+
}
|
package/src/utils/deep-equal.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {PointLike} from
|
|
1
|
+
import type { PointLike } from "../types/common";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Compare two points
|
|
@@ -41,7 +41,7 @@ export function deepEqual(a: any, b: any): boolean {
|
|
|
41
41
|
} else if (Array.isArray(b)) {
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
|
-
if (typeof a ===
|
|
44
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
45
45
|
const aKeys = Object.keys(a);
|
|
46
46
|
const bKeys = Object.keys(b);
|
|
47
47
|
if (aKeys.length !== bKeys.length) {
|
package/src/utils/set-globals.ts
CHANGED
|
@@ -1,57 +1,51 @@
|
|
|
1
1
|
export type GlobalSettings = {
|
|
2
|
-
/** The map's default API URL for requesting tiles, styles, sprites, and glyphs. */
|
|
3
|
-
baseApiUrl?: string;
|
|
4
2
|
/** The maximum number of images (raster tiles, sprites, icons) to load in parallel.
|
|
5
3
|
* @default 16
|
|
6
4
|
*/
|
|
7
5
|
maxParallelImageRequests?: number;
|
|
8
6
|
/** The map's RTL text plugin. Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left. */
|
|
9
|
-
RTLTextPlugin?: string |
|
|
10
|
-
/**
|
|
11
|
-
Takes precedence over `workerUrl`. */
|
|
12
|
-
workerClass?: any;
|
|
13
|
-
/** The number of web workers instantiated on a page with mapbox-gl maps.
|
|
7
|
+
RTLTextPlugin?: string | { pluginUrl: string; lazy?: boolean };
|
|
8
|
+
/** The number of web workers instantiated on a page with maplibre-gl maps.
|
|
14
9
|
* @default 2
|
|
15
10
|
*/
|
|
16
11
|
workerCount?: number;
|
|
17
|
-
/** Provides an interface for loading
|
|
12
|
+
/** Provides an interface for loading maplibre-gl's WebWorker bundle from a self-hosted URL.
|
|
18
13
|
* This is useful if your site needs to operate in a strict CSP (Content Security Policy) environment
|
|
19
14
|
* wherein you are not allowed to load JavaScript code from a Blob URL, which is default behavior. */
|
|
20
15
|
workerUrl?: string;
|
|
21
16
|
};
|
|
22
17
|
|
|
23
|
-
const globalSettings = [
|
|
24
|
-
'baseApiUrl',
|
|
25
|
-
'maxParallelImageRequests',
|
|
26
|
-
'workerClass',
|
|
27
|
-
'workerCount',
|
|
28
|
-
'workerUrl'
|
|
29
|
-
] as const;
|
|
30
|
-
|
|
31
18
|
export default function setGlobals(mapLib: any, props: GlobalSettings) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
mapLib[key] = props[key];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const {
|
|
39
|
-
RTLTextPlugin = 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js'
|
|
40
|
-
} = props;
|
|
19
|
+
const { RTLTextPlugin, maxParallelImageRequests, workerCount, workerUrl } =
|
|
20
|
+
props;
|
|
41
21
|
if (
|
|
42
22
|
RTLTextPlugin &&
|
|
43
23
|
mapLib.getRTLTextPluginStatus &&
|
|
44
|
-
mapLib.getRTLTextPluginStatus() ===
|
|
24
|
+
mapLib.getRTLTextPluginStatus() === "unavailable"
|
|
45
25
|
) {
|
|
26
|
+
const { pluginUrl, lazy = true } =
|
|
27
|
+
typeof RTLTextPlugin === "string"
|
|
28
|
+
? { pluginUrl: RTLTextPlugin }
|
|
29
|
+
: RTLTextPlugin;
|
|
30
|
+
|
|
46
31
|
mapLib.setRTLTextPlugin(
|
|
47
|
-
|
|
32
|
+
pluginUrl,
|
|
48
33
|
(error?: Error) => {
|
|
49
34
|
if (error) {
|
|
50
35
|
// eslint-disable-next-line
|
|
51
36
|
console.error(error);
|
|
52
37
|
}
|
|
53
38
|
},
|
|
54
|
-
|
|
39
|
+
lazy,
|
|
55
40
|
);
|
|
56
41
|
}
|
|
42
|
+
if (maxParallelImageRequests !== undefined) {
|
|
43
|
+
mapLib.setMaxParallelImageRequests(maxParallelImageRequests);
|
|
44
|
+
}
|
|
45
|
+
if (workerCount !== undefined) {
|
|
46
|
+
mapLib.setWorkerCount(workerCount);
|
|
47
|
+
}
|
|
48
|
+
if (workerUrl !== undefined) {
|
|
49
|
+
mapLib.setWorkerUrl(workerUrl);
|
|
50
|
+
}
|
|
57
51
|
}
|
package/src/utils/style-utils.ts
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { StyleSpecification } from "../types/style-spec";
|
|
2
|
+
import type { ImmutableLike } from "../types/common";
|
|
2
3
|
|
|
3
|
-
const refProps = [
|
|
4
|
+
const refProps = [
|
|
5
|
+
"type",
|
|
6
|
+
"source",
|
|
7
|
+
"source-layer",
|
|
8
|
+
"minzoom",
|
|
9
|
+
"maxzoom",
|
|
10
|
+
"filter",
|
|
11
|
+
"layout",
|
|
12
|
+
];
|
|
4
13
|
|
|
5
14
|
// Prepare a map style object for diffing
|
|
6
15
|
// If immutable - convert to plain object
|
|
7
16
|
// Work around some issues in older styles that would fail Mapbox's diffing
|
|
8
17
|
export function normalizeStyle(
|
|
9
|
-
style: string |
|
|
10
|
-
): string |
|
|
18
|
+
style: string | StyleSpecification | ImmutableLike<StyleSpecification>,
|
|
19
|
+
): string | StyleSpecification {
|
|
11
20
|
if (!style) {
|
|
12
21
|
return null;
|
|
13
22
|
}
|
|
14
|
-
if (typeof style ===
|
|
23
|
+
if (typeof style === "string") {
|
|
15
24
|
return style;
|
|
16
25
|
}
|
|
17
|
-
if (
|
|
26
|
+
if ("toJS" in style) {
|
|
18
27
|
style = style.toJS();
|
|
19
28
|
}
|
|
20
29
|
if (!style.layers) {
|
|
@@ -26,10 +35,10 @@ export function normalizeStyle(
|
|
|
26
35
|
layerIndex[layer.id] = layer;
|
|
27
36
|
}
|
|
28
37
|
|
|
29
|
-
const layers = style.layers.map(layer => {
|
|
38
|
+
const layers = style.layers.map((layer) => {
|
|
30
39
|
let normalizedLayer: typeof layer = null;
|
|
31
40
|
|
|
32
|
-
if (
|
|
41
|
+
if ("interactive" in layer) {
|
|
33
42
|
normalizedLayer = Object.assign({}, layer);
|
|
34
43
|
// Breaks style diffing :(
|
|
35
44
|
// @ts-ignore legacy field not typed
|
|
@@ -55,5 +64,5 @@ export function normalizeStyle(
|
|
|
55
64
|
});
|
|
56
65
|
|
|
57
66
|
// Do not mutate the style object provided by the user
|
|
58
|
-
return {...style, layers};
|
|
67
|
+
return { ...style, layers };
|
|
59
68
|
}
|
package/src/utils/transform.ts
CHANGED
|
@@ -1,86 +1,58 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Make a copy of a transform
|
|
7
|
-
* @param tr
|
|
8
|
-
*/
|
|
9
|
-
export function cloneTransform(tr: Transform): Transform {
|
|
10
|
-
const newTransform = tr.clone();
|
|
11
|
-
// Work around mapbox bug - this value is not assigned in clone(), only in resize()
|
|
12
|
-
newTransform.pixelsToGLUnits = tr.pixelsToGLUnits;
|
|
13
|
-
return newTransform;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Copy projection from one transform to another. This only applies to mapbox-gl transforms
|
|
18
|
-
* @param src the transform to copy projection settings from
|
|
19
|
-
* @param dest to transform to copy projection settings to
|
|
20
|
-
*/
|
|
21
|
-
export function syncProjection(src: Transform, dest: Transform): void {
|
|
22
|
-
if (!src.getProjection) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const srcProjection = src.getProjection();
|
|
26
|
-
const destProjection = dest.getProjection();
|
|
27
|
-
|
|
28
|
-
if (!deepEqual(srcProjection, destProjection)) {
|
|
29
|
-
dest.setProjection(srcProjection);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
import type { MaplibreProps } from "../maplibre/maplibre";
|
|
2
|
+
import type { ViewState } from "../types/common";
|
|
3
|
+
import type { TransformLike } from "../types/internal";
|
|
4
|
+
import { deepEqual } from "./deep-equal";
|
|
32
5
|
|
|
33
6
|
/**
|
|
34
7
|
* Capture a transform's current state
|
|
35
8
|
* @param transform
|
|
36
9
|
* @returns descriptor of the view state
|
|
37
10
|
*/
|
|
38
|
-
export function transformToViewState(tr:
|
|
11
|
+
export function transformToViewState(tr: TransformLike): ViewState {
|
|
39
12
|
return {
|
|
40
13
|
longitude: tr.center.lng,
|
|
41
14
|
latitude: tr.center.lat,
|
|
42
15
|
zoom: tr.zoom,
|
|
43
16
|
pitch: tr.pitch,
|
|
44
17
|
bearing: tr.bearing,
|
|
45
|
-
padding: tr.padding
|
|
18
|
+
padding: tr.padding,
|
|
46
19
|
};
|
|
47
20
|
}
|
|
48
21
|
|
|
49
22
|
/* eslint-disable complexity */
|
|
50
23
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @
|
|
53
|
-
* @param viewState
|
|
54
|
-
* @returns true if the transform has changed
|
|
24
|
+
* Applies requested view state to a transform
|
|
25
|
+
* @returns an object containing detected changes
|
|
55
26
|
*/
|
|
56
|
-
export function applyViewStateToTransform(
|
|
27
|
+
export function applyViewStateToTransform(
|
|
28
|
+
/** An object that describes Maplibre's camera state */
|
|
29
|
+
tr: TransformLike,
|
|
30
|
+
/** Props from Map component */
|
|
31
|
+
props: MaplibreProps,
|
|
32
|
+
): Partial<TransformLike> {
|
|
57
33
|
const v: Partial<ViewState> = props.viewState || props;
|
|
58
|
-
|
|
34
|
+
const changes: Partial<TransformLike> = {};
|
|
59
35
|
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
36
|
+
if (
|
|
37
|
+
"longitude" in v &&
|
|
38
|
+
"latitude" in v &&
|
|
39
|
+
(v.longitude !== tr.center.lng || v.latitude !== tr.center.lat)
|
|
40
|
+
) {
|
|
41
|
+
const LngLat = tr.center.constructor;
|
|
42
|
+
// @ts-expect-error we should not import LngLat class from maplibre-gl because we don't know the source of mapLib
|
|
43
|
+
changes.center = new LngLat(v.longitude, v.latitude);
|
|
64
44
|
}
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
tr.bearing = v.bearing;
|
|
68
|
-
changed = changed || bearing !== tr.bearing;
|
|
45
|
+
if ("zoom" in v && v.zoom !== tr.zoom) {
|
|
46
|
+
changes.zoom = v.zoom;
|
|
69
47
|
}
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
tr.pitch = v.pitch;
|
|
73
|
-
changed = changed || pitch !== tr.pitch;
|
|
48
|
+
if ("bearing" in v && v.bearing !== tr.bearing) {
|
|
49
|
+
changes.bearing = v.bearing;
|
|
74
50
|
}
|
|
75
|
-
if (v
|
|
76
|
-
|
|
77
|
-
tr.padding = v.padding;
|
|
51
|
+
if ("pitch" in v && v.pitch !== tr.pitch) {
|
|
52
|
+
changes.pitch = v.pitch;
|
|
78
53
|
}
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
// @ts-ignore
|
|
82
|
-
tr.center = new center.constructor(v.longitude, v.latitude);
|
|
83
|
-
changed = changed || center !== tr.center;
|
|
54
|
+
if (v.padding && tr.padding && !deepEqual(v.padding, tr.padding)) {
|
|
55
|
+
changes.padding = v.padding;
|
|
84
56
|
}
|
|
85
|
-
return
|
|
57
|
+
return changes;
|
|
86
58
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// From https://github.com/streamich/react-use/blob/master/src/useIsomorphicLayoutEffect.ts
|
|
2
2
|
// useLayoutEffect but does not trigger warning in server-side rendering
|
|
3
|
-
import {useEffect, useLayoutEffect} from
|
|
3
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
4
4
|
|
|
5
|
-
const useIsomorphicLayoutEffect =
|
|
5
|
+
const useIsomorphicLayoutEffect =
|
|
6
|
+
typeof document !== "undefined" ? useLayoutEffect : useEffect;
|
|
6
7
|
|
|
7
8
|
export default useIsomorphicLayoutEffect;
|