1
1
import React from 'react'
2
2
import Link from 'next/link'
3
3
import PropTypes from 'prop-types'
4
- import Button from '../../components/Button/Button'
4
+ import Button , { buttonPropTypes } from '../../components/Button/Button'
5
5
import './linked-button.css'
6
6
7
7
/**
@@ -16,18 +16,23 @@ const LinkedButton = ({ addClass, buttonProps, path }) => (
16
16
< ButtonLinkWrapper
17
17
addClass = { addClass }
18
18
buttonProps = { buttonProps }
19
- href = { path }
20
19
/>
21
20
</ Link >
22
21
)
23
22
24
- const ButtonLinkWrapper = React . forwardRef ( ( { addClass, buttonProps, href } , ref ) => (
25
- < a href = { href } ref = { ref } className = { addClass } >
26
- < Button { ...buttonProps } />
27
- </ a >
28
- ) )
23
+ const ButtonLinkWrapper = React . forwardRef ( ( { ...props } , ref ) => {
24
+ // eslint-disable-next-line react/prop-types
25
+ const { addClass, buttonProps, href } = props
26
+
27
+ return (
28
+ < a href = { href } ref = { ref } className = { addClass } >
29
+ < Button { ...buttonProps } />
30
+ </ a >
31
+ )
32
+ } )
33
+
34
+ const { onClick, ...remainingPropTypes } = buttonPropTypes
29
35
30
- const { onClick, ...remainingPropTypes } = Button . propTypes
31
36
LinkedButton . propTypes = {
32
37
buttonProps : PropTypes . shape ( remainingPropTypes ) . isRequired ,
33
38
addClass : PropTypes . string ,
@@ -41,4 +46,15 @@ LinkedButton.defaultProps = {
41
46
addClass : '' ,
42
47
}
43
48
49
+ ButtonLinkWrapper . propTypes = {
50
+ addClass : PropTypes . string ,
51
+ buttonProps : PropTypes . shape ( remainingPropTypes ) . isRequired ,
52
+ }
53
+
54
+ ButtonLinkWrapper . defaultProps = {
55
+ addClass : '' ,
56
+ }
57
+
58
+ ButtonLinkWrapper . displayName = 'Button Link Wrapper'
59
+
44
60
export default LinkedButton
0 commit comments