hops-react
Version:
React and ReactRouter setup for Hops
18 lines (14 loc) • 492 B
JavaScript
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;