module Gargantext.Hooks.Router (useHashRouter) whereimport Prelude (($), bind, discard, const, pure)import Data.Tuple.Nested ((/\))import Reactix as Rimport Routing.Match (Match)import Routing.Hash (matches)-- | Ties the hash router to a state hook of routes-- | Note: if it gets sent to an unrecognised url, it will quietly drop the changeuseHashRouter :: forall routes. Match routes -> routes -> R.Hooks (R.State routes)useHashRouter routes init = do route@(_ /\ setRoute) <- R.useState' init R.useEffectOnce $ matches routes $ \_old new -> setRoute (const new) pure route