Merge pull request #24278 from umidbekkarimov/expo-app-loading

[expo] Allow to render `<AppLoading />` without props.
This commit is contained in:
Eloy Durán
2018-03-14 07:31:13 -04:00
committed by GitHub
9 changed files with 25 additions and 41 deletions

View File

@@ -199,10 +199,7 @@ async () => {
onError={(error) => console.log(error)} />
);
() => (
<AppLoading
startAsync={null}
onFinish={null}
onError={null} />
<AppLoading />
);
const barcodeReadCallback = () => {};

13
types/expo/index.d.ts vendored
View File

@@ -5,6 +5,7 @@
// Jan Aagaard <https://github.com/janaagaard75>
// Sergio Sánchez <https://github.com/ssanchezmarc>
// Fernando Helwanger <https://github.com/fhelwanger>
// Umidbek Karimov <https://github.com/umidbekkarimov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
@@ -99,20 +100,16 @@ export namespace Amplitude {
// #region AppLoading
/** The following props are recommended, but optional for the sake of backwards compatibility (they were introduced in SDK21). If you do not provide any props, you are responsible for coordinating loading assets, handling errors, and updating state to unmount the `AppLoading` component. */
export type AppLoadingProps = {
export interface AppLoadingProps {
/** A `function` that returns a `Promise`. The `Promise` should resolve when the app is done loading data and assets. */
startAsync: () => Promise<void>;
startAsync?: () => Promise<void>;
/** Required if you provide `startAsync`. Called when `startAsync` resolves or rejects. This should be used to set state and unmount the `AppLoading` component. */
onFinish: () => void;
onFinish?: () => void;
/** If `startAsync` throws an error, it is caught and passed into the function provided to `onError`. */
onError?: (error: Error) => void;
} | {
startAsync: null;
onFinish: null;
onError?: null;
};
}
/**
* A React component that tells Expo to keep the app loading screen open if it is the first and only component rendered in your app. When it is removed, the loading screen will disappear and your app will be visible.

View File

@@ -2,6 +2,7 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"dom",
"es6"
],
"jsx": "react",
@@ -21,4 +22,4 @@
"index.d.ts",
"expo-tests.tsx"
]
}
}

View File

@@ -106,10 +106,7 @@ async () => {
onError={(error) => console.log(error)} />
);
() => (
<AppLoading
startAsync={null}
onFinish={null}
onError={null} />
<AppLoading />
);
const barcodeReadCallback = () => {};

View File

@@ -330,15 +330,12 @@ export class Video extends Component<VideoProps, VideoState> {
/**
* AppLoading
*/
export type AppLoadingProperties = {
startAsync: () => Promise<void>;
onFinish: () => void;
export interface AppLoadingProperties {
startAsync?: () => Promise<void>;
onFinish?: () => void;
onError?: (error: Error) => void;
} | {
startAsync: null;
onFinish: null;
onError?: null;
};
}
export class AppLoading extends Component<AppLoadingProperties> { }
/**

View File

@@ -2,7 +2,8 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
"es6",
"dom"
],
"jsx": "react",
"noImplicitAny": true,
@@ -29,4 +30,4 @@
"index.d.ts",
"expo-tests.tsx"
]
}
}

View File

@@ -196,10 +196,7 @@ async () => {
onError={(error) => console.log(error)} />
);
() => (
<AppLoading
startAsync={null}
onFinish={null}
onError={null} />
<AppLoading />
);
const barcodeReadCallback = () => {};

View File

@@ -99,20 +99,16 @@ export namespace Amplitude {
// #region AppLoading
/** The following props are recommended, but optional for the sake of backwards compatibility (they were introduced in SDK21). If you do not provide any props, you are responsible for coordinating loading assets, handling errors, and updating state to unmount the `AppLoading` component. */
export type AppLoadingProps = {
export interface AppLoadingProps {
/** A `function` that returns a `Promise`. The `Promise` should resolve when the app is done loading data and assets. */
startAsync: () => Promise<void>;
startAsync?: () => Promise<void>;
/** Required if you provide `startAsync`. Called when `startAsync` resolves or rejects. This should be used to set state and unmount the `AppLoading` component. */
onFinish: () => void;
onFinish?: () => void;
/** If `startAsync` throws an error, it is caught and passed into the function provided to `onError`. */
onError?: (error: Error) => void;
} | {
startAsync: null;
onFinish: null;
onError?: null;
};
}
/**
* A React component that tells Expo to keep the app loading screen open if it is the first and only component rendered in your app. When it is removed, the loading screen will disappear and your app will be visible.

View File

@@ -2,7 +2,8 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
"es6",
"dom"
],
"jsx": "react",
"noImplicitAny": true,
@@ -29,4 +30,4 @@
"index.d.ts",
"expo-tests.tsx"
]
}
}