0

I am using react-router witch mean i am storing routes in app.tsx file.

I have cards components who need to redirect to external url on click.

So my question is how to redirect on click on card component using the external url example: www.test.com and give to that url two query strings a=xxx b=xxx.

Fresh
  • 47
  • 4

2 Answers2

2

You can redirect to an external URL with dynamic query strings with template literals:

const onClick = () => {
  location.href = `www.test.com/?a=${queryA}&b=${queryB}`
}

where queryA and queryB are your dynamic injected query strings

Al Duncanson
  • 511
  • 4
  • 14
1

Is that what you need?

const onClick = () => {
    location.href = 'http://<location>/?a=1';
}
Yoskutik
  • 1,609
  • 2
  • 6
  • 25