replace instance of withRouter with useRouter

main
Mike Fix 4 years ago
parent b2912786a4
commit a9b4c9597b
No known key found for this signature in database
GPG Key ID: 1D85E862314CA79F

@ -1,5 +1,5 @@
import React from 'react' import React from 'react'
import { withRouter } from 'next/router' import { useRouter } from 'next/router'
import { useCopyTextHandler, useAsyncCallback } from 'actionsack' import { useCopyTextHandler, useAsyncCallback } from 'actionsack'
import morph from 'morphmorph' import morph from 'morphmorph'
@ -30,12 +30,13 @@ function CopyButton(props) {
) )
} }
const CopyEmbed = withRouter(({ router: { asPath }, mapper, title }) => { function CopyEmbed({ mapper, title }) {
const { asPath } = useRouter()
const text = React.useMemo(() => mapper(asPath), [mapper, asPath]) const text = React.useMemo(() => mapper(asPath), [mapper, asPath])
const { onClick, copied } = useCopyTextHandler(text) const { onClick, copied } = useCopyTextHandler(text)
return <CopyButton onClick={onClick}>{copied ? 'Copied!' : title}</CopyButton> return <CopyButton onClick={onClick}>{copied ? 'Copied!' : title}</CopyButton>
}) }
const popoutStyle = { width: '140px', right: 0 } const popoutStyle = { width: '140px', right: 0 }

Loading…
Cancel
Save