UNPKG

@macrof/shared

Version:

React MicroFrontend Shared, Typescript, Webpack 5, ModuleFederation

15 lines (14 loc) 563 B
import { createBrowserHistory } from 'history'; import { observable } from 'mobx'; import { includedPath } from '../utils'; const lastHashed = observable.object({ key: '' }); export const mfHistory = ((history) => () => { // eslint-disable-next-line no-param-reassign history.navigate = function navigate(key, isDefault) { if (isDefault || (key !== lastHashed.key && !includedPath(key, this.location.pathname))) { lastHashed.key = key; this.push(key); } }; return history; })(createBrowserHistory(window));