Utility Hooks
Other than the useRoutes
hook, Rocon provides two utility hooks.
useHistory
useHistory()
just returns current history object. Although it allows direct manipulation of current location with history.push
, it is not recommended as it cannot benefit from Rocon's type safety. Direct access to the history object is useful for listening to history change, or performing history.back()
, for example.
useLocation
useLocation()
returns current location object. It triggers a re-rendering whenever current location changes.