How to use the history/lib/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 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 sourcecred / sourcecred / src / homepage / index.js View on Github external
const target = document.getElementById("root");
if (target == null) {
  throw new Error("Unable to find root element!");
}

let initialRoot: string = target.dataset.initialRoot;
if (initialRoot == null) {
  console.error(
    `Initial root unset (${initialRoot}): this should not happen! ` +
      'Falling back to ".".'
  );
  initialRoot = ".";
}
const basename = normalize(`${window.location.pathname}/${initialRoot}/`);
const history = createRelativeHistory(createBrowserHistory(), basename);

const routeData = createRouteDataFromEnvironment();
ReactDOM.hydrate(, target);

// In Chrome, relative favicon URLs are recomputed at every pushState,
// although other assets (like the `src` of an `img`) are not. We don't
// want to have to keep the shortcut icon's path up to date as we
// transition; it's simpler to make it absolute at page load.
for (const el of document.querySelectorAll('link[rel="shortcut icon"]')) {
  const link: HTMLLinkElement = (el: any);
  // (Appearances aside, this is not a no-op.)
  link.href = link.href; // eslint-disable-line no-self-assign
}
github fabric-lab / hyperledger-fabric-manager / app / main.js View on Github external
import React from 'react';
import ReactDOM from 'react-dom';
import { HashRouter } from 'react-router-dom'
import createBrowserHistory from 'history/lib/createBrowserHistory';
import routes from './routes';
import { addLocaleData,IntlProvider } from 'react-intl'; 
import en from 'react-intl/locale-data/en';
import zh from 'react-intl/locale-data/zh';
import zh_CN from './message/zh_CN';
import en_US from './message/en_US';


let history = createBrowserHistory();
let locale   = "en"
let messages = en_US
addLocaleData([...en, ...zh]);
if(window.location.href.indexOf("zh_CN")!=-1){
     locale   = "zh"
     messages = zh_CN
}
const errorReporter = (error, locale, message) =>{ 
    // custom error reporting code here
}
ReactDOM.render( {routes}, document.getElementById('app'));
github freeqaz / redux-simple-router-example / index.jsx View on Github external
// React components for Redux DevTools
import {DevTools, DebugPanel, LogMonitor} from 'redux-devtools/lib/react';

const reducer = combineReducers(Object.assign({}, reducers, {
  routing: routeReducer
}));

const finalCreateStore = __DEVTOOLS ? compose(
  // Provides support for DevTools:
  devTools(),
  // Lets you write ?debug_session= in address bar to persist debug sessions
  persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
)(createStore) : createStore;

const store = finalCreateStore(reducer);
const history = createBrowserHistory();

syncReduxAndRouter(history, store);

ReactDOM.render(
  <div>
    
      
        {getRoutes()}
      
    
    { __DEVTOOLS &amp;&amp;
    
      
    
    }
  </div>,
github darul75 / personal-blog / app / app-dev.js View on Github external
// LIBRARY
/*eslint-disable no-unused-vars*/
import React from 'react';
/*eslint-enable no-unused-vars*/
import {render} from 'react-dom';
import {Router} from 'react-router';
import createBrowserHistory from 'history/lib/createBrowserHistory';

// DEPENDENCY
import routes from './routes';

const history = createBrowserHistory();

if(typeof document !== 'undefined' &amp;&amp; window) {
  window.onload = () =&gt; {
    render(, document.getElementById('app'));
  };
}
github khlieng / dispatch / client / src / js / app.js View on Github external
localStorage.uuid = uuid = util.UUID();
}

socket.on('connect', () =&gt; socket.send('uuid', uuid));
socket.on('error', error =&gt; console.log(error.server + ': ' + error.message));

const routes = (
	
		
		
		
		
		
	
);
const history = createBrowserHistory();

render(, document.getElementById('root'));
github wapgear / redux-react-material-boilerplate / src / client / index.js View on Github external
import 'babel-core/register';
import ReactDOM from 'react-dom';
import React from 'react';
import { Router } from 'react-router';
import { Provider } from 'react-redux';
import { ReduxRouter } from 'redux-router';
import createBrowserHistory from 'history/lib/createBrowserHistory'
import configureStore from '../common/store/configureStore';
import routes from '../common/routes';
import "../../styles/index.css";
const history = createBrowserHistory();
const initialState = window.__INITIAL_STATE__;
const store = configureStore(initialState);
const rootElement = document.getElementById('root');
console.log(`suck it:`);
console.log(routes);
ReactDOM.render(
    
        
            
        
    ,
    document.getElementById('root')
);
if (process.env.NODE_ENV !== 'production') {
    var devtools = require('../server/devtools');
    devtools.default(store);
github ele828 / higo / frontend / src / Router.js View on Github external
import React from 'react';

import { Router, Route, Link } from 'react-router';
import createBrowserHistory from 'history/lib/createBrowserHistory';
import Home from './Component/Home';
import List from './Component/List';
import Article from './Component/Article';
import About from './Component/About';

import Construction from './Component/Construction';

const history = createBrowserHistory()

export default class AppRouter extends React.Component {
  render() {
    return (
          
            
            
            
            
            
            
            
          
        );
  }
}
github mikey1384 / twinkle-network / client / index.jsx View on Github external
import React                from 'react';
import { render }           from 'react-dom';
import { Router }           from 'react-router';
import createBrowserHistory from 'history/lib/createBrowserHistory'
import { Provider }         from 'react-redux';
import * as reducers        from 'reducers';
import routes               from 'routes';
import promiseMiddleware    from 'lib/promiseMiddleware';
import immutifyState        from 'lib/immutifyState';
import { createStore,
         combineReducers,
         applyMiddleware }  from 'redux';

const initialState = immutifyState(window.__INITIAL_STATE__);

const history = createBrowserHistory();

const reducer = combineReducers(reducers);
const store   = applyMiddleware(promiseMiddleware)(createStore)(reducer, initialState);

render(
  
    
  ,
  document.getElementById('react-view')
);