How to inherit query parameters on Link Component without knowledge of the location object
<p>My App has some globally available query parameters <code>?from=2016-05-01&amp;to=2016-05-7&amp;interval=daily</code></p>

<p>I am using react-router 2.4.0 and the <code>location</code> object is available via <code>props</code> on all of the routing components.</p>

<p>So whenever I am on a Component where the <code>location</code> object is available I can simply do this to keep the query params on the link:</p>

<pre><code>&lt;Link to={{ pathname: '/whatever', query: this.props.location.query }}&gt;
   whatever
&lt;/Link&gt;
</code></pre>

<p>By now I pass down the <code>location</code> as <code>prop</code> to all child components that need to have links with inherited query params. But I quickly realized that nearly any Component needs to know the location because I want to have the opportunity to put links anywhere. This endet up in very long prop chains.</p>

<p>Currently the Link Component itself does not provide an API for query inheritance, so I am wondering if anyone has a good workaround for a Link Component that can be placed anywhere but can inherit the query params!?</p>

<p>Update: 
I'd like to thank QoP for his answer but I forgot to mention that getting the location from the context is also no suitable solution for me, as all parent Components lose their 'pureness' which means that I can't rely on 'shallowCompare' anymore.</p>