UNPKG

1.1 kBJavaScriptView Raw
1import * as React from 'react';
2import { Platform, Text } from 'react-native';
3import useLinkProps from './useLinkProps';
4
5/**
6 * Component to render link to another screen using a path.
7 * Uses an anchor tag on the web.
8 *
9 * @param props.to Absolute path to screen (e.g. `/feeds/hot`).
10 * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.
11 * @param props.children Child elements to render the content.
12 */
13export default function Link(_ref) {
14 let {
15 to,
16 action,
17 ...rest
18 } = _ref;
19 const props = useLinkProps({
20 to,
21 action
22 });
23
24 const onPress = e => {
25 if ('onPress' in rest) {
26 var _rest$onPress;
27
28 (_rest$onPress = rest.onPress) === null || _rest$onPress === void 0 ? void 0 : _rest$onPress.call(rest, e);
29 }
30
31 props.onPress(e);
32 };
33
34 return /*#__PURE__*/React.createElement(Text, { ...props,
35 ...rest,
36 ...Platform.select({
37 web: {
38 onClick: onPress
39 },
40 default: {
41 onPress
42 }
43 })
44 });
45}
46//# sourceMappingURL=Link.js.map
\No newline at end of file