How to use the history.useBasename 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 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 kenCode-de / bitshares-wallet / dev / app / app.jsx View on Github external
import PrivateKeyActions from "actions/PrivateKeyActions";
import AccountRefsStore from "stores/AccountRefsStore";
import ChainTypes from "./components/Utility/ChainTypes";
import NotificationStore from "stores/NotificationStore";

import AltContainer from "alt/AltContainer";

import injectTapEventPlugin from 'react-tap-event-plugin';
import If from './components/If';
import TransactionConfirm from './components/TransactionConfirm';
import IdleTimer from 'react-idle-timer';


import { createHashHistory, useBasename } from 'history';

const history = useBasename(createHashHistory)({});

//Needed for React Developer Tools
window.React = React;

injectTapEventPlugin();
/*
const history = useBasename(createHistory)({
  basename: '/index.html'
})
*/

require("./components/Utility/Prototypes"); // Adds a .equals method to Array for use in shouldComponentUpdate
require("dl_cli_index").init(window) // Adds some object refs to the global window object

// Main app component
class App extends React.Component {
github salesforce-ux / design-system / app_modules / site / browser / site.js View on Github external
route.getComponent = function(location, callback) {
          requirePage(`./${r.modulePath}`)(pageElement => {
            // HACK: ReactRouter requires a component, so we inject
            // the pageElement into the route
            route.page = pageElement.default;
            callback(null, App);
          });
        };
      }
      return route;
    });
    let history = createHistory();
    let versionPattern = /^\/(\d+|\d+\.\d+\.\d)\//;
    let versionMatch = versionPattern.exec(window.location.pathname);
    if (versionMatch) {
      history = useBasename(createHistory)({
        basename: `/${versionMatch[1]}`
      });
    }
    setHistory(history);
    // Return the router using HTML5 pushState
    return React.createElement(Router, {
      history: history,
      onUpdate: function () {
        logCurrentPageVisit();
        shared.store = shared.store.set('route', sitemap.getRouteByPath(
          this.state.location.pathname
        ));
        // Restore the preferences hash after a page change
        Prefs.sync(false);
      }
    }, ...routes);
github kenCode-de / bitshares-wallet / dev / app / dl / src / stores / TradeBeforeSendStore.js View on Github external
import alt from "alt-instance"
import TradeBeforeSendActions from "actions/TradeBeforeSendActions"
import WalletDb from "stores/WalletDb"
import SettingsStore from "stores/SettingsStore"

import { createHashHistory, useBasename } from 'history';
const history = useBasename(createHashHistory)({});

class TradeBeforeSendStore {

    constructor() {
        this.bindActions(TradeBeforeSendActions)
        this.state = {locked: true, unclosable:false}
	console.log('store constructor tbs setState', WalletDb.isLocked())
    }

    onUnlock({resolve, reject}) {
        console.log('store onUnlock tbs setState', WalletDb.isLocked());
	//this.setState({open:true});
        if( ! WalletDb.isLocked()) {
      //  if(true) { // TODO for test
            resolve()
            return
github reactuate / reactuate / src / createStore.js View on Github external
      createHistory: basename ? (() => useBasename(createHistory)({basename})) : createHistory
    }),
github stevenhauser / i-have-to-return-some-videotapes / src / utils / createStore.js View on Github external
const createHistoryWithBasename = (opts = {}) => {
  return useBasename(createHistory)({
    ...opts,
    basename: `/${BASE_PATH}`
  });
};
github taikongfeizhu / webpack-develop-startkit / src / utils / withBasename.js View on Github external
export default function withBasename (history, dirname) {
  return useBasename(() => history)({ basename: `/${dirname}` })
}
github AlastairTaft / draft-js-editor / examples / src / App.js View on Github external
import React, { Component } from 'react'
import Layout from './Layout'
import Home from './pages/Home'
import { Router } from 'react-router'
import { createHistory, useBasename } from 'history'
import routes from './routes'

const browserHistory = useBasename(createHistory)({
  basename: '/draft-js-editor'
})


const rootRoute = {
  childRoutes: [ {
    path: '/',
    component: Layout,
    indexRoute: {
    	component: Home,
    },
    childRoutes: routes,
  } ]
}
github sean-ww / react-redux-datatable / example / index.jsx View on Github external
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, Route, IndexRoute } from 'react-router';
import { createHistory, useBasename } from 'history';

import store from './store';

import Example from './example';

const history = useBasename(createHistory)({
  basename: window.location.pathname,
});

const app = document.getElementById('root');

ReactDOM.render(
  
    
      
        
      
    
  ,
  app,
);