How to use the history/createHashHistory 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 geeknull / earlyjoy / client-react / redux / index.js View on Github external
import { createStore, compose, applyMiddleware } from 'redux';

// 所有的 reducer
import allReducer from './reducer/index.js';

/* 中间件相关的开始 */
// 路由信息的中间件
import { routerMiddleware } from 'react-router-redux';
import createHistory from 'history/createHashHistory';
const history = createHistory();
const historyMiddleware = routerMiddleware(history);
// 异步中间件
import thunk from 'redux-thunk';
// 中间件数组
let middleware = [thunk, historyMiddleware];
/* 中间件相关的结束 */

// composeEnhancers 等同于 compose
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

let store = createStore(
  allReducer,
  composeEnhancers(
    applyMiddleware(...middleware)
  )
);
github LedgerHQ / ledger-live-desktop / src / renderer / createStore.js View on Github external
export default ({ state, history, dbMiddleware }: Props) => {
  if (!history) {
    history = createHistory()
  }
  const middlewares = [routerMiddleware(history), thunk, logger]
  if (!process.env.STORYBOOK_ENV) {
    middlewares.push(require('middlewares/sentry').default)
    middlewares.push(require('middlewares/analytics').default)
  }
  if (dbMiddleware) {
    middlewares.push(dbMiddleware)
  }
  const enhancers = compose(
    applyMiddleware(...middlewares),
    window.devToolsExtension ? window.devToolsExtension() : f => f, // eslint-disable-line
  )
  // $FlowFixMe
  return createStore(reducers, state, enhancers)
}
github apache / skywalking-ui / src / index.js View on Github external
* limitations under the License.
 */

import './polyfill';
import dva from 'dva';

import createHistory from 'history/createHashHistory';
// user BrowserHistory
// import createHistory from 'history/createBrowserHistory';
import createLoading from 'dva-loading';
import 'moment/locale/zh-cn';

import './index.less';
// 1. Initialize
const app = dva({
  history: createHistory(),
});

// 2. Plugins
app.use(createLoading());

// 3. Register global model
app.model(require('./models/global').default);

// 4. Router
app.router(require('./router').default);

// 5. Start
app.start('#root');

export default app._store; // eslint-disable-line
github bluedaniel / Kakapo-app / app / scripts / stores / configureStore.js View on Github external
import { applyMiddleware, createStore } from 'redux';
import { connectRouter, routerMiddleware } from 'connected-react-router';
import { composeWithDevTools } from 'remote-redux-devtools';
import createHashHistory from 'history/createHashHistory';
import createSagaMiddleware from 'redux-saga';
import rootReducer from 'reducers/';
import sagas from 'sagas/';

export const history = createHashHistory();

const sagaMiddleware = createSagaMiddleware();

export default () => {
  const middlewares = [sagaMiddleware, routerMiddleware(history)];

  const store = createStore(
    connectRouter(history)(rootReducer),
    window.__INITIAL_STATE__, // eslint-disable-line no-underscore-dangle
    composeWithDevTools(applyMiddleware(...middlewares))
  );

  sagaMiddleware.run(sagas);

  return store;
};
github genany / gen / src / index.js View on Github external
import './assets/common.less';
import App from './App';
import registerServiceWorker, { unregister } from './registerServiceWorker';
import { hot } from 'react-hot-loader';

import dva from 'dva';
import createHistory from 'history/createHashHistory';
// user BrowserHistory
// import createHistory from 'history/createBrowserHistory';
import createLoading from 'dva-loading';
import 'moment/locale/zh-cn';
import { createLogger } from 'redux-logger';

// 1. Initialize
const app = dva({
  history: createHistory(),
  onAction: createLogger({ level: 'log' })
});

app.use(createLoading());

app.model(require('./models/global').default);
app.model(require('./models/app').default);
app.model(require('./models/template').default);
app.model(require('./models/component').default);
app.model(require('./models/inter').default);
app.model(require('./models/interApp').default);
app.model(require('./models/layout').default);
app.model(require('./models/page').default);
app.model(require('./models/preview').default);
app.model(require('./models/scaffold').default);
app.model(require('./models/user').default);
github LedgerHQ / ledger-live-desktop / src / renderer / init.js View on Github external
async function init() {
  checkLibs({
    NotEnoughBalance,
    React,
    log,
    Transport,
  })

  db.init(userDataDirectory)
  db.registerTransform('app', 'accounts', { get: decodeAccountsModel, set: encodeAccountsModel })

  const history = createHistory()
  const store = createStore({ history, dbMiddleware })

  const settings = await db.getKey('app', 'settings')
  store.dispatch(fetchSettings(settings))

  const countervaluesData = await db.getKey('app', 'countervalues')
  if (countervaluesData) {
    store.dispatch(CounterValues.importAction(countervaluesData))
  }

  const state = store.getState()
  const language = languageSelector(state)
  moment.locale(language)

  const hideEmptyTokenAccounts = hideEmptyTokenAccountsSelector(state)
  setEnvOnAllThreads('HIDE_EMPTY_TOKEN_ACCOUNTS', hideEmptyTokenAccounts)
github cadbox1 / glue-stack / ui / src / common / history.js View on Github external
import createHashHistory from "history/createHashHistory";
import queryString from "query-string";

export const history = createHashHistory();

function addLocationQuery(history) {
	history.location = Object.assign(history.location, {
		query: queryString.parse(history.location.search),
	});
}

addLocationQuery(history);

history.listen(() => {
	addLocationQuery(history);
});

export function replaceParams(changedParams) {
	const { location } = history;
	const newParams = {
github nos / client / src / components / Root / Root.js View on Github external
import React from 'react';
import { Provider } from 'react-redux';
import { ConnectedRouter } from 'react-router-redux';
import createHistory from 'history/createHashHistory';

import Routes from './Routes';
import configureStore from '../../store/configureStore';

const history = createHistory();
const store = configureStore(history);

export default function Root() {
  return (
    
      
        
      
    
  );
}
github posm / OpenMapKitServer / frontend / src / index.js View on Github external
import { Router } from "react-router-dom";
import { Provider } from "react-redux";
import createHistory from "history/createHashHistory";

import "bootstrap/dist/css/bootstrap.css";
import "bootstrap/dist/css/bootstrap-theme.css";
import '@blueprintjs/core/lib/css/blueprint.css';
import '@blueprintjs/table/lib/css/table.css';
import '@blueprintjs/icons/lib/css/blueprint-icons.css';
import '@blueprintjs/datetime/lib/css/blueprint-datetime.css';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import { store } from './store';

const history = createHistory()

ReactDOM.render(
  
    
      
    
  ,
  document.getElementById('root'));
registerServiceWorker();
github cam-inc / viron / s / core / router.js View on Github external
start(autoExec = true) {
    this._history = createHashHistory();
    this._unlistener = this._history.listen((location, action) => {
      this._change(location, action);
    });

    if (autoExec) {
      this._change(this.getCurrentLocation(), this.getCurrentAction());
    }
  }