How to pass a value from ‘href’ prop to ‘to’ prop while mocking a module

  Kiến thức lập trình

I am trying to mock a Next/Link component and substitute it with a react router link component.
Everything goes well except that I don’t know how to pass the url from the ‘href’ porp of Next/Link to the ‘to’ prop of React Router Link.

Here is some code:

vi.mock('next/link', async () => {
  const { Link } = await vi.importActual('react-router-dom');

  return { default: Link };
});

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT