title: react-router browserHistory.listen unlisten
body: <p>How can I unlisten to that route?
  My function "execute" keeps running one Im cliking on links</p>
  
  <pre class="lang-js prettyprint-override"><code>const unlisten = browserHistory.listen(unlis);
  </code></pre>
  
  <p>function handleUrl(location) {
      const newPath = location.pathname;
      if (!newPath.includes(<code>${id})</code>)) {
        execute();
        unlisten(window.location);
      }
      else unlisten(window.location);
    browserHistory.listen(handleUrl);
    handleUrl(window.location);</p>
  
  
  
  <p>Ive tried to do:</p>
  
  <pre class="lang-js prettyprint-override"><code>  browserHistory.push(`/search/${id}');
  
    const unlisten = browserHistory.listen(location);
  
    function handleUrl(location) {
      const newPath = location.pathname;
      if (!newPath.includes(`${id})`) {
        execute();
        unlisten(window.location);
      else unliste;
    browserHistory.listen(handleUrl);
    handleUrl(window.location);
  </code></pre>
  
  
  
  <p>but no luck</p>