import { useEffect, useRef } from 'react'; import Icon from '../../common/Icon'; import DSBackToTop from '@scottish-government/design-system/dist/scripts/components/back-to-top/back-to-top'; import { BackToTopProps } from './types'; import clsx from 'clsx'; const BackToTop = ({ className, href = '#page-top', ...props }: BackToTopProps) => { const ref = useRef(null); useEffect(() => { /* istanbul ignore else */ if (ref.current) { new DSBackToTop(ref.current).init(); } }, [ref]); return (
Back to top
); }; BackToTop.displayName = 'BackToTop'; export default BackToTop;