Skip to content

Commit fa72a7d

Browse files
docs: add README example
1 parent 97a577b commit fa72a7d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/Hyperlink/README.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ categories:
77
- Buttonlike
88
status: 'Needs Work'
99
designStatus: 'Done'
10-
devStatus: 'To Do'
10+
devStatus: 'Done'
1111
notes: |
1212
Improve prop naming. Deprecate content prop.
1313
Use React.forwardRef for ref forwarding.
@@ -100,3 +100,18 @@ notes: |
100100
</div>
101101
</div>
102102
```
103+
104+
## with custom link element
105+
106+
``Hyperlink`` typically relies on the standard HTML anchor tag (i.e., ``a``); however, this behavior may be overriden when the destination link is to an internal route where it should be using routing instead (e.g., ``Link`` from React Router).
107+
108+
```jsx live
109+
<Hyperlink
110+
as={GatsbyLink}
111+
// `destination` is still a required prop even though the `to` takes precedence.
112+
destination="/components/button"
113+
to="/components/button"
114+
>
115+
Button
116+
</Hyperlink>
117+
```

src/Hyperlink/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import isRequiredIf from 'react-proptype-conditional-require';
34
import classNames from 'classnames';
45
import {
56
type BsPrefixRefForwardingComponent as ComponentWithAsProp,
@@ -119,6 +120,7 @@ Hyperlink.defaultProps = {
119120
};
120121

121122
Hyperlink.propTypes = {
123+
/** specifies the component element type to render for the hyperlink */
122124
as: PropTypes.elementType,
123125
/** specifies the URL */
124126
destination: PropTypes.string.isRequired,

0 commit comments

Comments
 (0)