UNPKG

hops-react

Version:
18 lines (14 loc) 492 B
import { Mixin } from 'hops-mixin'; import { createElement } from 'react'; import { BrowserRouter } from 'react-router-dom'; import { ensureLeadingSlash, trimTrailingSlash } from 'pathifist'; class ReactRouterMixin extends Mixin { enhanceElement(element) { const props = { ...this.options.router, basename: trimTrailingSlash(ensureLeadingSlash(this.config.basePath)), }; return createElement(BrowserRouter, props, element); } } export default ReactRouterMixin;