import React, {ReactNode} from 'react';
import {Link, NavLink, NavLinkProps, useLocation} from "react-router-dom";

interface NavLinkWithQueryProps extends NavLinkProps  {
    children?: ReactNode
}

const NavLinkWithQuery = ({ children, to, ...props }: NavLinkWithQueryProps) => {

    const { search } = useLocation();

    return (
        <NavLink to={to + search} {...props}>
            {children}
        </NavLink>
    );
}

export default NavLinkWithQuery;