mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
Update react-router-native types
* Fix AndroidBackButton children * Add BackButton component * Add initialEntries and initialIndex to NativeRouter
This commit is contained in:
Vendored
+8
-4
@@ -1,6 +1,7 @@
|
||||
// Type definitions for React Router Native 4.0
|
||||
// Type definitions for React Router Native 4.2
|
||||
// Project: https://github.com/ReactTraining/react-router-native
|
||||
// Definitions by: Eduard Zintz <https://github.com/ezintz>
|
||||
// Fernando Helwanger <https://github.com/fhelwanger>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
@@ -22,11 +23,12 @@ export {
|
||||
import * as React from 'react';
|
||||
import * as H from 'history';
|
||||
|
||||
export interface AndroidBackButtonProps {
|
||||
children: React.Component[];
|
||||
export interface BackButtonProps {
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
export class AndroidBackButton extends React.Component<AndroidBackButtonProps> {}
|
||||
export class BackButton extends React.Component<BackButtonProps> {}
|
||||
export class AndroidBackButton extends React.Component<BackButtonProps> {}
|
||||
|
||||
export class DeepLinking extends React.Component {}
|
||||
|
||||
@@ -42,6 +44,8 @@ export class Link extends React.Component<LinkProps> {}
|
||||
export interface NativeRouterProps {
|
||||
getUserConfirmation?: Function;
|
||||
keyLength?: number;
|
||||
initialEntries?: string[];
|
||||
initialIndex?: number;
|
||||
}
|
||||
|
||||
export class NativeRouter extends React.Component<NativeRouterProps> {}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
import { NativeRouter as Router, Route, Link } from 'react-router-native';
|
||||
import { NativeRouter as Router, Route, Link, AndroidBackButton, BackButton } from 'react-router-native';
|
||||
|
||||
const Home: React.SFC = () => {
|
||||
return (
|
||||
@@ -27,19 +27,22 @@ const About: React.SFC = () => {
|
||||
export default class App extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<Router>
|
||||
<View style={styles.container}>
|
||||
<View style={styles.nav}>
|
||||
<Link to="/" style={styles.navItem}>
|
||||
<Text>Home</Text>
|
||||
</Link>
|
||||
<Link to="/about" style={styles.navItem}>
|
||||
<Router initialEntries={['/']} initialIndex={0}>
|
||||
<BackButton />
|
||||
<AndroidBackButton>
|
||||
<View style={styles.container}>
|
||||
<View style={styles.nav}>
|
||||
<Link to="/" style={styles.navItem}>
|
||||
<Text>Home</Text>
|
||||
</Link>
|
||||
<Link to="/about" style={styles.navItem}>
|
||||
<Text>About</Text>
|
||||
</Link>
|
||||
</Link>
|
||||
</View>
|
||||
<Route exact path="/" component={Home} />
|
||||
<Route path="/about" component={About} />
|
||||
</View>
|
||||
<Route exact path="/" component={Home}/>
|
||||
<Route path="/about" component={About}/>
|
||||
</View>
|
||||
</AndroidBackButton>
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user