Bard mobx router

Bard mobx router

  • Github

›Router and routes

About Bard router

  • Philosophy
  • Getting started

Router and routes

  • Route specific hooks
  • Router hooks

React UI Components

  • <Route/>
  • <Link/>

Plugins

  • Scroll plugin
  • Window title plugin
  • Html5 history plugin

How to's

  • How-to's / FAQ

Router hooks

As opposed to route specific hooks, the router hooks are handlers that you want to call any time there is a navigation event.

Hooks available

  • beforeNav (called before the view / navigation transition)
  • afterNav (called after the view / navigation was done)

These handlers are called with an event object like this:

{
  router,             // reference to the router
  incomingRequest,    // the new request
  currentState,       // the current/previous request (depending on the point of view, after/before nav)
  goToOptions,        // goToOptions are mostly for internal purposes (like POP, goBack, ...)
}

Example

A typical use case is to scroll back to top when the user navigates to a different section of your app.

That's what the scrollPlugin does internally.

router.on('aferNav', () => window.scrollTo(0, 0))
← Route specific hooks<Route/> →
  • Hooks available
  • Example
Bard mobx router
Docs
Getting Started
Community
Who is using this?Chat on Gitter
More
GitHub
Copyright © 2023 Aodev