import domdom from '@eirikb/domdom'; type Route = 'panel-a' | 'panel-b'; interface Data { route: Route; } const { React, init, don, path, data } = domdom({ route: 'panel-a' }); const PanelA = () => (
Panel A :)
); const PanelB = () =>
Panel B! (hash is: {window.location.hash})
; const view = (
{don(path().route).map((route: Route) => { switch (route) { case 'panel-b': return ; default: return ; } })}
); function gotoRoute(route: Route) { window.location.hash = route; } window.addEventListener( 'hashchange', () => (data.route = window.location.hash.slice(1) as Route) ); init(document.body, view);