Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dyaa/f2295e107a569e4e5e33255bb2aabcf4 to your computer and use it in GitHub Desktop.

Select an option

Save dyaa/f2295e107a569e4e5e33255bb2aabcf4 to your computer and use it in GitHub Desktop.

Revisions

  1. @DimitryDushkin DimitryDushkin revised this gist Mar 7, 2017. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions react-router-queyry-utils.js
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,15 @@ export const addQuery = (query) => {
    browserHistory.push(location);
    };

    /**
    * @param {Object} query
    */
    export const replaceQuery = (query) => {
    const location = Object.assign({}, browserHistory.getCurrentLocation());
    Object.assign(location.query, query);
    browserHistory.replace(location);
    }

    /**
    * @param {...String} queryNames
    */
  2. @DimitryDushkin DimitryDushkin renamed this gist Feb 8, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. @DimitryDushkin DimitryDushkin created this gist Feb 8, 2017.
    19 changes: 19 additions & 0 deletions react-router-utils.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    import { browserHistory } from 'react-router';

    /**
    * @param {Object} query
    */
    export const addQuery = (query) => {
    const location = Object.assign({}, browserHistory.getCurrentLocation());
    Object.assign(location.query, query);
    browserHistory.push(location);
    };

    /**
    * @param {...String} queryNames
    */
    export const removeQuery = (...queryNames) => {
    const location = Object.assign({}, browserHistory.getCurrentLocation());
    queryNames.forEach(q => delete location.query[q]);
    browserHistory.push(location);
    };