Sorry, if this is a stupid question, but I'm just trying to have a URL entered into a field and then a button that, when clicked, will take the value in that field and open a new tab to that URL. If I do this:
onClick={event => {
event.preventDefault();
window.open('https://www.google.com/', '_blank');
}}
Then it works just fine and opens a new tab with the specified url.
But if I set urlText = "https://www.google.com/" and do this:
onClick={event => {
event.preventDefault();
window.open({urlText},'_blank');
}}
Then it opens a new tab, but it goes to this instead:
http://theCurrentWebsiteDomain/[object%20Object]
I assume it's trying to add the urlText to the end of the current domain, like it's a page that I'm specifying instead of a whole new URL.
I added a console.log and it displays urlText just fine. If I click on it from the console, it goes right to the expected website.
What am I doing wrong?