Popstate not firing before react UseEffect cleanup I have a more complex setup, but have boiled my hook down to the most minimum example: