Gitako/src/components/PJAXLink.tsx
2019-11-09 01:53:59 +08:00

14 lines
320 B
TypeScript

import * as React from 'react'
import * as DOMHelper from 'utils/DOMHelper'
type Props<P> = {
to: string
children: React.ReactElement<P>
}
export function PJAXLink<P>({ to, children }: Props<P>) {
return React.cloneElement(children, {
...children.props,
onClick: () => DOMHelper.loadWithPJAX(to),
})
}