Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
How to stop reloading screen when go back to previous screen with dom-router in react js

I have a web app with multiple pages and routing, in every single page I have table with lots of data, so every time I change page and press back button, the history page is reloads itself.

I want to keep the data of ListingPage as it is when I goBack to ListingPage from DetailPage. But every time it calls getAllRecords function and reloads the table.

I tried changing dom options and components but still not getting a proper solution

My App page structure is something like as below

App.js

import { BrowserRouter, Route, Switch } from 'react-router-dom';
import HomePage from './Pages/HomePage.js'
import ListingPage from './Pages/ListingPage.js'
import DetailPage from './Pages/DetailPage.js'
render() {
    return (
        <BrowserRouter>
            <Switch>
                <Route path="/home" component={HomePage} />
                <Route path="/list" component={ListingPage} />
                <Route path="/detail" component={DetailPage} />
            </Switch>
        </BrowserRouter>
    )
}

HomePage.js

import React, { Component } from 'react';
class HomePage extends Component {
    render() {
        return (
            <div>
                //Showing list of different table and pages
            </div>
        );
    }
}
export default HomePage;

ListingPage.js

import React, { Component } from 'react';
class ListingPage extends Component {
    componentDidMount(){
        this.getAllRecords()
    }
    getAllRecords = () => {}
    goToDetailRecord = () => {
        this.props.history.push('detail')
    }
    render() {
        return (
            <div>
                //Table list data
            </div>
        );
    }
}
export default ListingPage;

DetailPage.js

import React, { Component } from 'react';
class DetailPage extends Component {
    goBack = () => {
        this.props.history.goBack();
    }
    render() {
        return (
            <div>
                //Shows table data detail value
            </div>
        );
    }
}
export default DetailPage;

Is there anything I can implement to resolve the issue. Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can either useMemo or the react 16 and older version of that to store a cache to prevent it doing so on re renders or save the value in state using redux and not call the function if the field isn't empty. Also if component did mount works like useEffect I think by you having it there it will call that function on each re render.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!