How to use the createBrowserHistory function from history

Find comprehensive JavaScript history.createBrowserHistory code examples handpicked from public code repositorys.

21
22
23
24
25
26
27
28
29
30
        Link = reactRouter.Link;
        Redirect = reactRouter.Redirect;
        useParams = reactRouter.useParams;
        useRouteMatch = reactRouter.useRouteMatch;

        history = createBrowserHistory({ basename: window.basename || '/' });
        // eslint-disable-next-line
        Router = props => <reactRouter.Router {...props} history={history} location={history.location} />;
} catch (e) {
        if (process.env.NODE_ENV !== 'production') {
fork icon48
star icon148
watch icon45

+ 3 other calls in file

58
59
60
61
62
63
64
65
66
  action: 'PUSH' | 'REPLACE' | 'POP' | 'REFRESH' | 'BEFORE_NAVIGATE';
}
const listeners: Map<string, Listener> = new Map();
let currentLocation: uri.URI;

const history = h.createBrowserHistory();
history.listen((location, action) =>
  init(location).onValue((mUrl) => mUrl.map((url) => notifyAll({ url: url, action: action })))
);
fork icon31
star icon104
watch icon28

+ 11 other calls in file

25
26
27
28
29
30
31
32
33
34
const React = require('react');
const ReactDOM = require('react-dom');
const { createBrowserHistory } = require('history');

const scrollToDetailedStatus = () => {
  const history = createBrowserHistory();
  const detailedStatuses = document.querySelectorAll('.public-layout .detailed-status');
  const location = history.location;

  if (detailedStatuses.length === 1 && (!location.state || !location.state.scrolledToDetailedStatus)) {
fork icon0
star icon552
watch icon27

+ 9 other calls in file

0
1
2
3
4
5
6
7
8
9
const History = require('history');
const ConnectedRouter = require('connected-react-router');

module.exports = (m, { basePath }) => {

    const history = History.createBrowserHistory({
        basename: basePath
    });

    return {
fork icon7
star icon35
watch icon13

34
35
36
37
38
39
40
41
42
43
  console.log(props.data);
  return <h2>Home</h2>;
};

const router = new Router({
  history: history.createBrowserHistory(),
  routes: [
    {
      name: 'web',
      uri: '/',
fork icon1
star icon3
watch icon2

+ 3 other calls in file

3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
    args[_key] = arguments[_key];
  }

  _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
  _this.history = history.createBrowserHistory(_this.props);
  return _this;
}

var _proto = BrowserRouter.prototype;
fork icon0
star icon0
watch icon0

23
24
25
26
27
28
29
30
31
32
    return new BrowserRouter(getHistoryAdapter(type, options));
}
function getHistoryAdapter(type, options) {
    switch (type) {
        case 'memory': return history.createMemoryHistory(options);
        case 'browser': return history.createBrowserHistory(options);
        case 'hash':
        default:
            return history.createHashHistory(options);
    }
fork icon0
star icon0
watch icon0

3
4
5
6
7
8
9
10
11
12
import Callback from './components/Callback'
// import createHistory from 'history/createBrowserHistory' // <----- TBC if this fix is needed
import App from './App'
// const history = createHistory()
const createHistory = require('history')
const history = createHistory.createBrowserHistory()

const auth = new Auth(history)

const handleAuthentication = (props: any) => {
fork icon0
star icon0
watch icon2

+ 13 other calls in file

4
5
6
7
8
9
10
11
12
var history, router

// Simplify instantiating the history module for peeps
function autoPickHistory (value, opts) {
  if (value === 'hash') return History.createHashHistory(opts)
  if (value === 'pushState') return History.createBrowserHistory(opts)
  if (value === 'virtual') return History.createMemoryHistory(opts)
  throw new Error("Invalid value '" + value + "' for 'history' option in vue.$routr")
}
fork icon0
star icon0
watch icon2