Skip to content

Commit

Permalink
fix(docz): incompatible props on Link
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Mar 29, 2019
1 parent c643a1d commit 281cb13
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions core/docz/src/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import * as React from 'react'
import { useCallback } from 'react'
import { Link as BaseLink, LinkProps, LinkGetProps } from '@reach/router'
import { omit } from 'lodash/fp'

export { LinkProps }
export const Link = React.forwardRef<any, LinkProps<any>>((props, ref) => {
const isActive = useCallback(
({ isCurrent }: LinkGetProps) => {
return isCurrent ? { className: `${props.className} active` } : {}
},
[props.className]
)
export const Link = React.forwardRef<any, LinkProps<any>>(
(defaultProps, ref) => {
const props = omit(['activeClassName', 'partiallyActive'], defaultProps)
const isActive = useCallback(
({ isCurrent }: LinkGetProps) => {
return isCurrent ? { className: `${props.className} active` } : {}
},
[props.className]
)

return <BaseLink {...props} getProps={isActive} ref={ref} />
})
return <BaseLink {...props} getProps={isActive} ref={ref} />
}
)

Link.displayName = 'Link'

0 comments on commit 281cb13

Please sign in to comment.