JSFiddle - React, Tailwind, and code Playground

HTML

<body>
        <button onclick="clickHash()">hash</button>
        <button onclick="clickCancel()">cancel</button>
        <div style="height: 2000px; width: 1000px; background: red;"></div>
        <button onclick="clickCancel()">cancel</button>
        <script>
            clickHash = function(){
                location.hash = "#test";
                window.scrollTo(0, 2000);
            }
            clickCancel = function(){
                location.hash = "";
            }
            handler = function() {
              console.log("hashchange fired");
            }
            window.onhashchange = handler;
        </script>
    </body>