Skip to content

Commit 9b79869

Browse files
committed
Implment custom elementId prop
1 parent 891f825 commit 9b79869

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function genericHashLink(As) {
9090

9191
function handleClick(e) {
9292
reset();
93-
hashFragment = linkHash;
93+
hashFragment = props.elementId ? `#${props.elementId}` : linkHash;
9494
if (props.onClick) props.onClick(e);
9595
if (hashFragment !== '') {
9696
scrollFunction =
@@ -102,7 +102,7 @@ export function genericHashLink(As) {
102102
hashLinkScroll(props.timeout);
103103
}
104104
}
105-
const { scroll, smooth, timeout, ...filteredProps } = props;
105+
const { scroll, smooth, timeout, elementId, ...filteredProps } = props;
106106
return (
107107
<As {...passDownProps} {...filteredProps} onClick={handleClick} ref={ref}>
108108
{props.children}
@@ -120,6 +120,7 @@ const propTypes = {
120120
children: PropTypes.node,
121121
scroll: PropTypes.func,
122122
timeout: PropTypes.number,
123+
elementId: PropTypes.string,
123124
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
124125
};
125126

0 commit comments

Comments
 (0)