Skip to content

Commit

Permalink
fix(api-loader): fix type error. (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Apr 26, 2023
1 parent faf15e5 commit 2b51323
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/api-loader/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// <reference types="@uiw/react-amap-types" />

import { PropsWithChildren, useEffect, useState } from 'react';
import { FC, Fragment, PropsWithChildren, useEffect, useState } from 'react';
import { load } from '@amap/amap-jsapi-loader';

export type APILoaderConfig = PropsWithChildren<{
export interface APILoaderConfig {
/**
* key 密钥
* 您需先[申请密钥(ak)](https://lbs.amap.com/dev/key/app)。开发文档说明地址:https://lbs.amap.com/api/javascript-api/guide/abc/prepare
Expand Down Expand Up @@ -36,7 +36,7 @@ export type APILoaderConfig = PropsWithChildren<{
/** Loca 版本,缺省 1.3.2 */
version?: string;
};
}>;
}

export interface APILoaderProps extends APILoaderConfig {
/**
Expand All @@ -55,7 +55,7 @@ export interface APILoaderProps extends APILoaderConfig {
/**
* APILoader 用于加载百度地图依赖
*/
export const APILoader = (props: APILoaderProps) => {
export const APILoader: FC<PropsWithChildren<APILoaderProps>> = (props) => {
const { children, ...config } = props;
const [loaded, setLoaded] = useState(false);
const [error, setError] = useState<Error>();
Expand All @@ -80,7 +80,7 @@ export const APILoader = (props: APILoaderProps) => {
if (error) {
return <div style={{ color: 'red' }}>{error.message}</div>;
} else if (loaded) {
return children;
return <Fragment>{children}</Fragment>;
}
return null;
};

1 comment on commit 2b51323

@vercel
Copy link

@vercel vercel bot commented on 2b51323 Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

react-amap – ./

react-amap-398188662.vercel.app
react-amap-one.vercel.app
react-amap-git-master-398188662.vercel.app

Please sign in to comment.