N
N
nickname133842019-03-19 21:08:17
JavaScript
nickname13384, 2019-03-19 21:08:17

How to update state without reloading?

When sending data through a form (post), the data gets into json and is displayed on the page. To see the new data, you need to manually reload the page.
How to display this data without reloading?
Data is an array in state ={list: []}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hzzzzl, 2019-03-19
@hzzzzl

how is the "data gets into json and displayed on the page", through this.setState?

E
Egor Zhivagin, 2019-03-20
@Krasnodar_etc

- After POST, make a GET on new data, put it in the state
- See if some response of the POST request comes, maybe there is enough data from it to update the state
- In addition to sending data in the POST, also update them in stete
...
Depends on the specific task and API.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question