Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda