Using react 16, react-router 4.
My domain is suppose "https://www.xyz.c". I'm having anchor tag which should redirect to "https://www.xyz.c/some-path" without reloading the page.
- I can implement it using
<NavLink>and<Link>withto="/some-path". However, I need complete url to be shown in DOM (why? Well, on side note, I'm using itemProp for schema for which I want full path in anchor tag) - Implementing it with
<a>andprops.historytag like following causes to again replace with relative url, i.e. it becomeshttps://www.xyz.c/https://www.xyz.c/some-pathin the url.
<a data-url="https://www.xyz.c/some-path" onClick={this.onClick}>Label</a>
onClick = e => {
e.preventDefault();
this.props.history.push(urlFromDataSet);
}
This seems impossible with <Navlink>, <Link> or <a> + props.history, since the policy is that history.replace, or history.push works on url with same origin. My url is also of same origin, however, I'm giving full path in href.
However, facebook is achieving the same in its header (Check on FB by going to home page, once loaded completely, then Click on your own profile button in header. It doesn't reload the page.)
How can we do that?