Skip to content
Snippets Groups Projects
Commit 0c5ebe52 authored by esikkala's avatar esikkala
Browse files

Add separate history object

parent dc8bcb45
No related branches found
No related tags found
No related merge requests found
import { createBrowserHistory } from 'history';
export default createBrowserHistory();
......@@ -10,6 +10,7 @@ import CircularProgress from '@material-ui/core/CircularProgress';
import purple from '@material-ui/core/colors/purple';
import ResultTableHead from './ResultTableHead';
import { parse } from 'query-string';
import history from './History';
const styles = () => ({
tableContainer: {
......@@ -44,13 +45,8 @@ class ResultTable extends React.Component {
let page;
if (this.props.routeProps.location.search === '') {
page = this.props.data.page === -1 ? 0 : this.props.data.page;
this.props.routeProps.history.push({
pathname: `/${this.props.resultClass}/table`,
data: `?page=${this.props.data.page}`,
});
//console.log(`result table mounted WITHOUT page parameter, set page to ${page}`);
// console.log(`result table mounted WITHOUT page parameter, set page to ${page}`);
} else {
//console.log(this.props.routeProps.location.data)
page = parseInt(parse(this.props.routeProps.location.search).page);
// console.log(`result table mounted with page parameter, set page to ${page}`);
}
......@@ -60,13 +56,16 @@ class ResultTable extends React.Component {
componentDidUpdate = prevProps => {
if (prevProps.data.page != this.props.data.page) {
this.props.fetchPaginatedResults(this.props.resultClass, this.props.facetClass, this.props.variant);
this.props.routeProps.history.push({
// console.log('push to history')
// console.log(this.props.data.page)
history.push({
pathname: `/${this.props.resultClass}/table`,
data: `?page=${this.props.data.page}`,
search: `?page=${this.props.data.page}`,
});
}
if (prevProps.filters != this.props.filters) {
this.props.updatePage(this.props.resultClass, 0);
// if already on page 0, fetch results
if (this.props.data.page == 0) {
this.props.fetchPaginatedResults(this.props.resultClass, this.props.facetClass, this.props.variant);
}
......
......@@ -6,7 +6,7 @@ import {responsiveStoreEnhancer} from 'redux-responsive';
import { Provider } from 'react-redux';
import ReduxToastr, { actions as toastrActions } from 'react-redux-toastr';
import { Router } from 'react-router-dom';
import { createBrowserHistory } from 'history';
import history from './components/History';
import 'react-redux-toastr/lib/css/react-redux-toastr.min.css';
import 'react-virtualized/styles.css';
......@@ -15,7 +15,7 @@ import rootEpic from './epics';
import App from './components/App';
const epicMiddleware = createEpicMiddleware();
const history = createBrowserHistory();
const store = createStore(
reducer,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment