From the course: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Handling browser navigation history
From the course: Learning Full-Stack JavaScript Development: MongoDB, Node, and React
Handling browser navigation history
- [Instructor] When we go to the page for a single contest right now, we just change the state of the application to render that, but we have not changed the URL. Ideally, every contest should get its own URL so that we can share this contest with others. To do that in a single page application, we will have to use the history API, this is not something supported by React, there is no React API to manipulate the history API, but there are libraries out there like React Router that wraps the history API and provides its own API for us to use. But for this course, I'm going to use the native DOM history API, I think it's simple enough for us to use, and I think it's important to understand the core client routing using the native history API. So on the window object in every browser there is a history class, and it has a few functions, the one we need to change a URL of page is pushState, and as you can see from Chrome,…
Contents
-
-
-
-
-
-
Invoking component actions in children7m 40s
-
(Locked)
Displaying a different root component4m 7s
-
(Locked)
Fetching data after navigating to a new view7m 15s
-
(Locked)
Handling browser navigation history7m 14s
-
(Locked)
Server-side rendering of a custom path7m 28s
-
(Locked)
Fetching data conditionally4m 16s
-
(Locked)
Navigating on link click6m 11s
-
-