A
A
ar52016-09-20 17:48:30
JavaScript
ar5, 2016-09-20 17:48:30

How to force react to draw a component from scratch?

Good afternoon, please tell me how to tell a component in React to render from 0. I use the React+redux+react-router bundle. There is a main page and a page of type /?id=uiid64. And when you go to the /?id=uiid64 url, the previous state is displayed, and then it changes. I would like to render this page from 0.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2016-09-20
@ar5

In the reducer, start a variable, for example, isFetching with a true / false state at the time of the execution of an asynchronous request (true on REQUEST, false on SUCCESS).
In the component template, style this moment with the isFetching variable as you like: for example, you show a preloader that completely overlaps the previous data and is somehow animated. The most primitive example:

...
render()
...
  if (this.props.isFetching) {
    <p> Loading...</p>
  } else {
    <p> {ВАШИ_ДАННЫЕ} </p>
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question