How to use the history.createBrowserHistory 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 vanilla / vanilla / library / src / scripts / state / getStore.ts View on Github external
/**
 * @copyright 2009-2018 Vanilla Forums Inc.
 * @license GPL-2.0-only
 */

import { createStore, compose, applyMiddleware, combineReducers, Store } from "redux";
import { getReducers } from "@library/state/reducerRegistry";
import thunk from "redux-thunk";
import { createBrowserHistory } from "history";
import { connectRouter, routerMiddleware } from "connected-react-router";

const history = createBrowserHistory();

// There may be an initial state to import.
const initialState = {};
const initialActions = window.__ACTIONS__ || [];

const middleware = [thunk, routerMiddleware(history)];

// Browser may have redux dev tools installed, if so integrate with it.
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const enhancer = composeEnhancers(applyMiddleware(...middleware));

// Build the store, add devtools extension support if it's available.
let store;

export default function getStore<s>(): Store<s> {
    if (store === undefined) {</s></s>
github rrecuero / fstack-ethdapp-template / client / src / index.js View on Github external
import MyStringStore from './contracts/MyStringStore.json';

// import css
import 'font-awesome/css/font-awesome.min.css';
import 'bulma/bulma.sass';
import './index.scss';

const auth = new Auth();

// let drizzle know what contracts we want
const options = { contracts: [MyStringStore] };

// setup the drizzle store and drizzle
const drizzleStore = generateStore(options);
const drizzle = new Drizzle(options, drizzleStore);
const history = createBrowserHistory();


ReactDOM.render((
github NickMaev / react-core-boilerplate / RCB.TypeScript / ClientApp / boot-client.tsx View on Github external
function setupGlobalPlugins() {
    // Use dot notation in the name attributes of the form inputs.
    NSerializeJson.options.useDotSeparatorInPath = true;
};

function setupEvents() {
    document.addEventListener('DOMContentLoaded', () =&gt; {
        var preloader = document.getElementById("preloader");
        preloader.classList.add("hidden");
    });
};

// Create browser history to use in the Redux store.
const baseUrl = document.getElementsByTagName('base')[0].getAttribute('href')!;
const history = createBrowserHistory({ basename: baseUrl });

// Get the application-wide store instance, prepopulating with state from the server where available.
const initialState = (window as any).initialReduxState as ApplicationState;
const store = configureStore(history, initialState);

function renderApp() {
    // This code starts up the React app when it runs in a browser. It sets up the routing configuration
    // and injects the app into a DOM element.
    ReactDOM.hydrate(
        
            
                
            
        ,
        document.getElementById('react-app')
    );
github wearepush / push-starter / src / client / index.js View on Github external
import '@babel/polyfill';

import React from 'react';
import { hydrate } from 'react-dom';
import { createBrowserHistory as createHistory } from 'history';

import Root from './root';
import ApiClient from '../helpers/ApiClient';
import getRoutes from '../routes/routes';
import config from '../config';
import configureStore from '../redux/store';

const client = new ApiClient();
const initialState = window.__INITIAL_STATE__;
const history = createHistory();
const store = configureStore(history, client, initialState);
const dest = document.getElementById('root');

let renderApp = renderProps =&gt; hydrate(
  ,
  dest
);

if (config.env === 'development') {
  const RedBox = require('redbox-react').default;
  const { AppContainer } = require('react-hot-loader');
  renderApp = renderProps =&gt; hydrate(
github getheimdall / heimdall / frontend / src / index.js View on Github external
import routingMiddleware from './middlewares/active-router'
import { I18nextProvider } from 'react-i18next'
import i18n from './i18n/i18n'

import { LocaleProvider } from 'antd'
import en_US from 'antd/lib/locale-provider/en_US'
import App from './containers/App'

import 'react-joyride/lib/react-joyride-compiled.css'
import 'nprogress/nprogress.css'
import 'react-table/react-table.css'
import './theme.less'
import './styles.less'


const history = createBrowserHistory()

const middleware = [thunk]

middleware.push(routingMiddleware);
const composeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const store = createStore(
  connectRouter(history)(rootReducer),
  composeEnhancer(
    applyMiddleware(
      routerMiddleware(history),
      ...middleware,
    ),
  ),
)

const render = () => {
github zerobias / effector / examples / react-ssr / src / client.tsx View on Github external
import React from 'react'
import ReactDOM from 'react-dom'
import {createBrowserHistory} from 'history'
import {fork, allSettled} from 'effector/fork'
import {App, app, location$, startClient} from './app'

const history = createBrowserHistory()

location$.updates.watch(location =&gt; {
  if (history.location !== location) {
    history.push(location)
  }
})

const clientScope = fork(app, {
  values: window.__initialState__,
})

allSettled(startClient, {
  scope: clientScope,
  params: history,
}).then(() =&gt; {
  ReactDOM.hydrate(, document.getElementById('root'))
github Uniswap / uniswap-frontend / src / pages / Pool / CreateExchange.js View on Github external
useEffect(() => {
    const history = createBrowserHistory()
    history.push(window.location.pathname + '')
  }, [])
github artemdemo / react-webpack-starter / source / history.js View on Github external
import { createBrowserHistory } from 'history';

const customHistory = createBrowserHistory();

export default customHistory;
github tinylog / tinylog-ui / src / app / index.tsx View on Github external
CommonDataStore,
  PageStore,
  RealTimeStore  
} from './stores';
import registerServiceWorker from './registerServiceWorker';
import { Root } from './containers/Root';
import './index.css';
import Container from './containers/Container';
import SignIn from './containers/Auth/signIn';
import SignUp from './containers/Auth/signUp';
import './macarons';
import 'echarts/map/js/world';

useStrict(true);

const browserHistory = createBrowserHistory();
const routerStore =  new RouterStore();
const history = syncHistoryWithStore(browserHistory, routerStore);
const rootStore = {
  token: new TokenStore(),
  auth: new AuthStore(),
  host: new HostStore(),
  overview: new OverViewStore(),
  assets: new AssetsStore(),
  commmon: new CommonDataStore(),
  page: new PageStore(),
  realtime: new RealTimeStore(),
  router: routerStore
};

ReactDOM.render(
github sinnerschrader / feature-hub / packages / history-service / src / internal / create-history-multiplexers.ts View on Github external
get browserHistoryMultiplexer(): HistoryMultiplexer {
      if (!browserHistoryMultiplexer) {
        browserHistoryMultiplexer = new HistoryMultiplexer(
          history.createBrowserHistory(),
          rootLocationTransformer
        );
      }

      return browserHistoryMultiplexer;
    },