Skip to content
Snippets Groups Projects
Commit 0a868536 authored by Jorik Schellekens's avatar Jorik Schellekens
Browse files

Update app on hashchange

parent c000c17a
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and ...@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React from 'react'; import React, { useState, useEffect } from 'react';
import SingleColumn from './layouts/SingleColumn'; import SingleColumn from './layouts/SingleColumn';
import CreateLinkTile from './components/CreateLinkTile'; import CreateLinkTile from './components/CreateLinkTile';
...@@ -36,9 +36,13 @@ const App: React.FC = () => { ...@@ -36,9 +36,13 @@ const App: React.FC = () => {
</> </>
); );
if (location.hash) { const [hash, setHash] = useState(location.hash);
if (location.hash.startsWith('#/')) {
page = <LinkRouter link={location.hash.slice(2)} />; useEffect(() => (window.onhashchange = () => setHash(location.hash)), []);
if (hash) {
if (hash.startsWith('#/')) {
page = <LinkRouter link={hash.slice(2)} />;
} else { } else {
page = ( page = (
<Tile> <Tile>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment