Merge pull request #30694 from stackbuilders/master

Fix children type for react-native-dialog
This commit is contained in:
Andrew Casey
2018-12-05 17:42:57 -08:00
committed by GitHub
2 changed files with 23 additions and 1 deletions
+3 -1
View File
@@ -1,6 +1,8 @@
// Type definitions for react-native-dialog 4.0
// Project: https://github.com/mmazzarolo/react-native-dialog
// Definitions by: MrLuje <https://github.com/MrLuje>
// Stack Builders <https://github.com/stackbuilders>
// Esteban Ibarra <https://github.com/ibarrae>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -32,7 +34,7 @@ interface ButtonProps {
interface ContainerProps {
blurComponentIOS?: ReactNode;
children: JSX.Element[];
children: React.ReactNode[];
/**
* default: false
*/
@@ -2,6 +2,24 @@ import Dialog from "react-native-dialog";
import { createRef, Component } from "react";
class Example extends Component {
dynamicButtons() {
const buttonFunc = () => console.log('click');
const buttons = [
{ label: 'Button 1', action: buttonFunc },
{ label: 'Button 2', action: buttonFunc },
];
return buttons.map(({ label , action }) =>
<Dialog.Button
label={label}
onPress={action}
/>
);
}
singleButton() {
return (<Dialog.Button label="Click" onPress={() => null} />);
}
render() {
const ref = createRef();
@@ -23,6 +41,8 @@ class Example extends Component {
label="Validate"
onPress={() => console.log("test")}
/>
{this.dynamicButtons()}
{this.singleButton()}
</Dialog.Container>
);
}