How to use the history.useQueries function in history

To help you get started, we’ve selected a few history examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / history / v2 / history-tests.ts View on Github external
history.listenBeforeUnload(function() {
        return 'Are you sure you want to leave this page?'
    })
}

{
    let history = useQueries(createHistory)()

    history.listen(function(location) {
        console.log(location.query)
    })
}

{
    let history = useQueries(createHistory)({
        parseQueryString: function(queryString) {
            // TODO: return a parsed version of queryString
            return {};
        },
        stringifyQuery: function(query) {
            // TODO: return a query string created from query
            return "";
        }
    })

    history.createPath({ pathname: '/the/path', query: { the: 'query' } })
    history.push({ pathname: '/the/path', query: { the: 'query' } })
}

{
    // Run our app under the /base URL.
github DefinitelyTyped / DefinitelyTyped / react-router / history-tests.ts View on Github external
history.listenBeforeUnload(function() {
        return 'Are you sure you want to leave this page?'
    })
}

{
    let history = useQueries(createHistory)()

    history.listen(function(location) {
        console.log(location.query)
    })
}

{
    let history = useQueries(createHistory)({
        parseQueryString: function(queryString) {
            // TODO: return a parsed version of queryString
            return {};
        },
        stringifyQuery: function(query) {
            // TODO: return a query string created from query
            return "";
        }
    })

    history.createPath({ pathname: '/the/path', query: { the: 'query' } })
    history.push({ pathname: '/the/path', query: { the: 'query' } })
}

{
    // Run our app under the /base URL.
github n8mellis / uswds-react / server / server.jsx View on Github external
server.get("*", (request, response, next) => {
  // Set up routing and history objects.
  let history = useRouterHistory(useQueries(createMemoryHistory))();
  let store = configureStore();
  let routes = createRoutes(history);
  let location = history.createLocation(request.url);
  
  // Use the `match` function to render the correct view.
  match({ routes, location }, (error, redirectLocation, renderProps) => {
    // If we have a `redirectLocation`, then set the redirect on the response 
    // and return.
    if (redirectLocation) {
      response.redirect(301, formatPath(redirectLocation));
      return;
    }
    // If we have an error object, set the HTTP status and message and return.
    if (error) {
      response.status(500).send(error.message);
      return;
github mozilla / advocacy.mozilla.org / src / encrypt-app.js View on Github external
/* eslint-disable no-unused-vars */
import React from 'react';
/* eslint-disable no-unused-vars */
import { render } from 'react-dom';
import ga  from 'react-ga';
import { match, Router } from 'react-router';
import { createHistory, useQueries } from 'history';
import routes from './encrypt-main.js';

const history = useQueries(createHistory)();

ga.initialize(process.env.GA_TRACKING_ID);
match({routes, history }, (error, redirectLocation, renderProps) => {
  render(, document.getElementById(`my-app`));
});
github Cmdv / cycle-webpack-boilerplate / src / app.js View on Github external
import {makeDOMDriver}      from '@cycle/dom';
import {makeHistoryDriver}  from '@cycle/history';
import {useQueries, createHistory} from 'history';
import Rx                   from 'rx';
import Main                  from './main'
import {rerunner, restartable} from 'cycle-restart';

// we are pulling in our css files here for webpack to compile
require("!style!css!styles/pure-min.css");
require("!style!css!styles/layout.css");
require("!style!css!styles/grids-responsive-min.css");

// this is the Cycle run. first argument is our mainApp then an object:
// DOM is the ID or class we want the cycle to render onto our page
// History is using our makeHistoryDriver to deal with routing
const history = useQueries(createHistory)();
const drivers = {
  DOM: makeDOMDriver('#application'),
  History: makeHistoryDriver(history),
  Props: () => Rx.Observable.just(0)
};

const rerun = rerunner(run);
rerun(Main, drivers);

if (module && module.hot) {
  module.hot.accept('./main', () => {
    const main = require('./main').default;
    rerun(main, drivers);
  });
  module.hot.accept();
}
github searchkit / searchkit / lib / src / core / history.js View on Github external
exports.createHistory = function () {
    return history_1.useQueries(history_1.createHistory)({
        stringifyQuery: function (ob) {
            return qs.stringify(ob, { encode: true });
        },
        parseQueryString: function (str) {
            return qs.parse(str);
        }
    });
};
//# sourceMappingURL=history.js.map
github shalomeir / snippod-boilerplate / snippod-webapp / src / helpers / history.js View on Github external
//Deprecation Do not use this helper when you use react-router upper than 2.x. react-router provide history singletons.
//Reference: https://github.com/reactjs/react-router/blob/master/upgrade-guides/v2.0.0.md#changes-to-thiscontext

//Reference: https://github.com/rackt/react-router/blob/latest/docs/guides/advanced/NavigatingOutsideOfComponents.md
import { useQueries } from 'history';
import createBrowserHistory from 'history/lib/createBrowserHistory';
import createMemoryHistory from 'history/lib/createMemoryHistory';

let history;

if (__CLIENT__) {
  history = useQueries(createBrowserHistory)();
} else {
  history = useQueries(createMemoryHistory)();
}

export default history;
github mz026 / universal-redux-template / app / server / middlewares / universalRenderer.js View on Github external
export default (req, res, next)=> {
  let history = useRouterHistory(useQueries(createMemoryHistory))()
  let store = configureStore()
  let routes = createRoutes(history)
  let location = history.createLocation(req.url)

  match({ routes, location }, (error, redirectLocation, renderProps) => {
    if (redirectLocation) {
      res.redirect(301, redirectLocation.pathname + redirectLocation.search)
    } else if (error) {
      res.status(500).send(error.message)
    } else if (renderProps == null) {
      res.status(404).send('Not found')
    } else {
      let [ getCurrentUrl, unsubscribe ] = subscribeUrl()
      let reqUrl = location.pathname + location.search

      getReduxPromise().then(()=> {
github keystonejs / keystone-classic / admin / client / stores / CurrentListStore.js View on Github external
'use strict';

import { createHistory, useQueries } from 'history';
import Store from 'store-prototype';
import List from '../utils/List';

const history = useQueries(createHistory)();

let _location = null;
let _ready = false;
let _loading = false;
let _items = {};
let _itemsResultsClone = [];
let _list = {};

let active = {};

let page = {};

function defaultPage () {
	return {
		size: _list.perPage,
		index: 1,
github gcanti / tom / examples / react-router.js View on Github external
import React from 'react'
import { Router, Route, Redirect } from 'react-router'
import { createHashHistory, useQueries } from 'history'

const history = useQueries(createHashHistory)({ queryKey: false })

class A extends React.Component {
  render() {
    return (
      <div>
        <p>Current view: A</p>
        <a href="#/b">goto B</a>
      </div>
    )
  }
}

class B extends React.Component {
  render() {
    return (
      <div></div>