-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
30 lines (26 loc) · 949 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import React, { useEffect, useState } from "react";
import loadMap from "./../../libs/loadMap";
import defaults from "./../../libs/defaults";
import merge from "lodash.merge";
import initPlatform from "./../../libs/initPlatform";
const optionMerger = (options) => merge(defaults, options);
function Platform(props) {
const [platformData, setPlatformData] = useState({
platform: {},
options: {},
});
useEffect(() => {
// const { version, interactive, includeUI, includePlaces } = props;
loadMap(props).then((options) => {
const platform = initPlatform(options);
setPlatformData({ platform, options });
});
}, [platformData.platform.A]);
const { platform, options } = platformData;
return platform.A == "api.here.com" && options.apikey
? React.Children.map(props.children, (child) => {
return React.cloneElement(child, { platform, options });
})
: null;
}
export default Platform;