How to use the history.createMemoryHistory 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 cockroachdb / cockroach-gen / pkg / ui / cluster-ui / src / transactionsPage / transactions.fixture.ts View on Github external
// Copyright 2021 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

/* eslint-disable @typescript-eslint/camelcase */
import { createMemoryHistory } from "history";
import { cockroach } from "@cockroachlabs/crdb-protobuf-client";
import Long from "long";

const history = createMemoryHistory({ initialEntries: ["/transactions"] });

export const routeProps = {
  history,
  location: {
    pathname: "/transactions",
    search: "",
    hash: "",
    // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
    // @ts-ignore
    state: null,
  },
  match: {
    path: "/transactions",
    url: "/transactions",
    isExact: true,
    params: {},
github NickMaev / react-core-boilerplate / RCB.TypeScript / ClientApp / boot-server.tsx View on Github external
return new Promise((resolve, reject) => {

        // Prepare Redux store with in-memory history, and dispatch a navigation event.
        // corresponding to the incoming URL.
        const basename = params.baseUrl.substring(0, params.baseUrl.length - 1); // Remove trailing slash.
        const urlAfterBasename = params.url.substring(basename.length);
        const store = configureStore(createMemoryHistory());
        store.dispatch(replace(urlAfterBasename));

        // Prepare an instance of the application and perform an inital render that will
        // cause any async tasks (e.g., data access) to begin.
        const routerContext: any = {};
        const app = (
            
                
            
        );

        const renderApp = (): string => {
            return renderToString(app);
        };

        connect(params);
github forbole / big_dipper / imports / ui / App.jsx View on Github external
render() {
        const history = createMemoryHistory();

        return(
            // 
                <div>
                    {(Meteor.settings.public.gtm)?:''}
                    
                    
                        
                        
                            
                            </div>
github leonardodino / forex-web-app / src / test-utils / render-with-router.tsx View on Github external
const renderWithRouter = (
  ui: React.ReactElement,
  {
    route = '/',
    history = createMemoryHistory({ initialEntries: [route] }),
  } = {},
) =&gt; ({
  ...render({ui}),
  history,
})
github bradstiff / react-app-location / tests / integration.js View on Github external
function renderWithRouter(ui, url = '/') {
    const history = createMemoryHistory({ initialEntries: [url] });
    return {
        ...render({ui}),
        history,
    }
}
github Strikersoft / poa / src / router-lib / router.ts View on Github external
function createRouterInstallConfig(routerConfig: PoaRouteBootConfig): RouterInstallConfig {
  const getContext = () => {
    if (routerConfig.context) {
      return { ...routerConfig.context(), store: getStore(), actions: getActions() };
    }

    return { store: getStore(), actions: getActions() };
  };

  switch (routerConfig.type) {
    case RouterType.hash:
      return { history: createHashHistory(), routes: routerConfig.routes, getContext };
    case RouterType.memory:
      return { history: createMemoryHistory(), routes: routerConfig.routes, getContext };
    default:
      return { history: createBrowserHistory(), routes: routerConfig.routes, getContext };
  }
}
github zjuasmn / mobx-history / src / createMemoryHistory.js View on Github external
export default (props) => new History(createMemoryHistory(props));
github alexayan / dva-ssr / src / render.jsx View on Github external
async function renderFragment(createApp, routes, url, initialState, timeout, staticMarkup, ignoreTimeout) {
  let asyncTime = 0;
  let isTimeout = false;
  const render = staticMarkup ? renderToStaticMarkup : renderToString;
  const history = createMemoryHistory();
  history.push(url);
  const context = {};
  const app = createApp({
    history,
    initialState,
  });
  if (!existSSRModel(app)) {
    app.model(ssrModel);
  }
  app.router(options =&gt; (
    <div>{routes}</div>
  ));
  const asyncActions = getAsyncActions(app);
  const branch = findRouteByUrl(routes, url);
  if (branch.length === 0) {
    return {};
github JounQin / react-hackernews / src / store / index.js View on Github external
import { createBrowserHistory, createMemoryHistory } from 'history'
import { connectRouter, routerMiddleware } from 'connected-react-router'
import { compose, combineReducers, createStore, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'

import * as reducers from './reducers'

export const history = __SERVER__
  ? createMemoryHistory()
  : createBrowserHistory()

const composeEnhancers =
  (__DEV__ && !__SERVER__ && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
  compose

export default initialState =>
  createStore(
    combineReducers({
      router: connectRouter(history),
      ...reducers,
    }),
    initialState,
    composeEnhancers(applyMiddleware(routerMiddleware(history), thunk)),
  )
github unlock-protocol / unlock / paywall / src / createUnlockStore.js View on Github external
export const createUnlockStore = (
  defaultState = {},
  history = createMemoryHistory(),
  middlewares = []
) => {
  const reducers = {
    router: connectRouter(history),
    account: accountReducer,
    keys: keysReducer,
    locks: locksReducer,
    modals: modalReducer,
    network: networkReducer,
    provider: providerReducer,
    transactions: transactionsReducer,
    currency: currencyReducer,
    errors: errorsReducer,
    walletStatus: walletStatusReducer,
  }