How to use history - 10 common examples

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 / react-router / history-tests.ts View on Github external
let history = useBasename(createHistory)({
        basename: '/base'
    })

    // At the /base/hello/world URL:
    history.listen(function(location) {
        console.log(location.pathname) // /hello/world
        console.log(location.basename) // /base
    })

    history.createPath('/the/path') // /base/the/path
    history.push('/the/path') // push /base/the/path
}

{
    let history = createHistory()

    const { pathname, query, search, state} = history.getCurrentLocation()
    console.log(pathname)
    console.log(query)
    console.log(search)
    console.log(state)
}
github DefinitelyTyped / DefinitelyTyped / history / v2 / history-tests.ts View on Github external
// 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.
    let history = useBasename(createHistory)({
        basename: '/base'
    })

    // At the /base/hello/world URL:
    history.listen(function(location) {
        console.log(location.pathname) // /hello/world
        console.log(location.basename) // /base
    })

    history.createPath('/the/path') // /base/the/path
    history.push('/the/path') // push /base/the/path
}
github flow-typed / flow-typed / definitions / npm / history_v4.9.x / flow_v0.25.x- / test_history_v4.9.x.js View on Github external
it('should not allow to accept void', () => {
    // $ExpectError
    const location = parsePath()

    const state: {} = location
  });
});
github flow-typed / flow-typed / definitions / npm / history_v4.9.x / flow_v0.25.x- / test_history_v4.9.x.js View on Github external
it('should allow to use string argument', () => {
    const location = parsePath('/test?query#hash')

    const state: {} = location
    // $ExpectError
    const key: string = location
  });
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 py-in-the-sky / gae-flask-redux-react-starter-kit / browser_client / __test__ / e2e / setup.js View on Github external
beforeEach(function () {  // BEFORE EACH TEST
    this.appHistory = new createBrowserHistory();
    this.store = store;
    this.appRoot = renderIntoDocument(
        
    );
    this.findOnPage = createFinder(this.appRoot);
    this.navigate = path => this.appHistory.pushState(null, path);
});
github py-in-the-sky / gae-flask-redux-react-starter-kit / browser_client / __test__ / e2e / setup.js View on Github external
beforeEach(function () {  // BEFORE EACH TEST
    this.timeout(5000);  // see https://mochajs.org/#timeouts
    this.appHistory = new createBrowserHistory();
    this.store = store;
    this.appRoot = renderIntoDocument(
        
    );
    this.findOnPage = createFinder(this.appRoot);
    this.navigate = path => this.appHistory.pushState(null, path);
});
github taion / react-router-scroll / test / useScroll.spec.js View on Github external
function createHashHistoryWithoutKey() {
  // Avoid persistence of stored data from previous tests.
  window.sessionStorage.clear();

  return createHashHistory({ queryKey: false });
}
github prooph / event-store-mgmt-ui / src / index.tsx View on Github external
//                 Object
//                     .keys(res[lang])
//                     .forEach((namespace) => {
//                         i18next.addResourceBundle(lang, namespace, res[lang][namespace], true, true );
//                     })
//                 ;
//             })
//         ;
//
//         module.hot.emit('loaded');
//     });
// }

const sagaMiddleware = createSagaMiddleware();

const history = createHashHistory();

const initialState = INITIAL_STATE.set(PATH_MESSAGE_FLOW, loadMessageFlow())
    .setIn(WATCHERS_PATH, loadWatchers());

console.log("initial state", initialState.toJSON());

const store = createStore(
    reducer,
    initialState,
    composeWithDevTools(
        applyMiddleware(sagaMiddleware) as StoreEnhancer,
    ) as StoreEnhancer,
);

//Register localStorage sync
store.subscribe(() => {