basepath config as singleton

This commit is contained in:
Cássio Zen
2016-07-15 16:16:33 -03:00
parent e3643217de
commit b991b1af26
3 changed files with 14 additions and 3 deletions

10
src/routing/basePath.js Normal file
View File

@ -0,0 +1,10 @@
const base = document.querySelector('base');
let basePath;
if (base && base.href) {
basePath = base.attributes.getNamedItem('href').value;
} else {
basePath = '';
}
export default basePath;

View File

@ -1,10 +1,10 @@
import { createHistory } from 'history';
import { useRouterHistory } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import basePath from './basePath';
const base = document.querySelector('base');
let history = useRouterHistory(createHistory)({
basename: base && base.href || ''
basename: basePath
});
const syncHistory = (store) => {