open window using react-router v4's this.props.history.push?

Viewed 9274

I know we can use a Link tag and pass in target="_blank" like

<Link to="/" target="_blank">Hello World</Link>

but I am having trouble finding out I can do that with this.props.history.push... I am using that to pass in a pathname and search string...

    let searchString = queryString.stringify({
      rangeEnd: data.programEnd,
    });

    this.props.history({
      pathname: `/machines/${machineId}`,
      search: searchString,
      target: "_blank // need something like this, not seeing it in docs
    });
1 Answers

History push changes address in the same window.

One option could be using window.open()

const url = `#/machines/${machineId}?${searchString}`;
window.open(url);
Related