forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativeRouter.js
More file actions
29 lines (25 loc) · 801 Bytes
/
NativeRouter.js
File metadata and controls
29 lines (25 loc) · 801 Bytes
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
import React from "react";
import PropTypes from "prop-types";
import MemoryRouter from "react-router/MemoryRouter";
import { Alert } from "react-native";
/**
* The public API for a <Router> designed for React Native. Gets
* user confirmations via Alert by default.
*/
const NativeRouter = props => <MemoryRouter {...props} />;
NativeRouter.propTypes = {
initialEntries: PropTypes.array,
initialIndex: PropTypes.number,
getUserConfirmation: PropTypes.func,
keyLength: PropTypes.number,
children: PropTypes.node
};
NativeRouter.defaultProps = {
getUserConfirmation: (message, callback) => {
Alert.alert("Confirm", message, [
{ text: "Cancel", onPress: () => callback(false) },
{ text: "OK", onPress: () => callback(true) }
]);
}
};
export default NativeRouter;