-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New history event proposal #5562
Copy link
Copy link
Closed
Labels
addition/proposalNew features or enhancementsNew features or enhancementsneeds concrete proposalMoving the issue forward requires someone to figure out a detailed planMoving the issue forward requires someone to figure out a detailed planneeds implementer interestMoving the issue forward requires implementers to express interestMoving the issue forward requires implementers to express interesttopic: history
Metadata
Metadata
Assignees
Labels
addition/proposalNew features or enhancementsNew features or enhancementsneeds concrete proposalMoving the issue forward requires someone to figure out a detailed planMoving the issue forward requires someone to figure out a detailed planneeds implementer interestMoving the issue forward requires implementers to express interestMoving the issue forward requires implementers to express interesttopic: history
See this exact same proposal but in a different place: WICG/proposals#6
Proposal
Add an event called
statechangeorhistorychangethat will fire on any change to the history stack, whether that be through the browser's back button, orwindow.history.pushStateor other methods.This proposed event would be similar to
popstate, except that it would fire on all route changes regardless of the source, much likehashchangefires on all hash changes regardless of the source.Current Problems
hashchangeevents allowed javascript router libraries (e.g. React Router, vue-router) to easily respond to any routing event when the application is using hash routing.However, with the HTML5 History API, there is no equivalent event that javascript routers can listen to.
This means that routers have the following limitations/problems:
window.history.pushStatedirectly and must only use the Router's custom methodsReferences:
remix-run/react-router#6304
Example
Side notes
I hope I did this in the correct repo. Let me know if I need to change/update anything. Thanks.
This was created in collaboration with @joeldenning