简体   繁体   中英

React Router Auto Re-Render

If I have a component that submits a form and makes a post request, and I redirect to a page that shows the user's submissions, how do I make the page re-render?
It will show the most recent version of the page (current submission not included) because dependencies did not change, and I have to refresh manually for the added submission to show. I'm pretty sure I've found the answer for useHistory but since I have no idea what am I'm doing(I learned with useHistory ) I'm using useNavigate .

So how would I reflect the most recent submission immediately on redirect?

If the form submission data is coming from an API, then I guess it will automatically fetch new data on redirect. If you want to show form and data on the same page, then after submission of a form, fetch new data from API.

It will be easier to answer if you share your code.

Thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM