{"repo":"kitze/mobx-router","free":true,"listed":false,"github":"https://github.com/kitze/mobx-router","clone":"git clone https://github.com/kitze/mobx-router.git","description":"A simple router for MobX + React apps","language":"TypeScript","stars":504,"topics":["mobx","router","react","hooks","lifecycle-events","history"],"license":null,"category":"ui-components","readme_excerpt":"🙋‍♂️ Made by @thekitze Other projects: - 🏫 React Academy - Interactive React and GraphQL workshops - 💌 Twizzy - A standalone app for Twitter DM - 💻 Sizzy - A tool for testing responsive design on multiple devices at once - 🤖 JSUI - A powerful UI toolkit for managing JavaScript apps --- 〽️ MobX Router Example usage Demo project Demo project repo Demo project repo with typescript Inspiration 📖 How to decouple state and UI - a.k.a. you don’t need componentWillMount Features - Decoupled state from UI - Central route configuration - URL changes are triggering changes directly in the store, and vice-versa - No need to use component lifecycle methods like componentWillMount to fetch data or trigger a side effect in the store - Supported callbacks for the routes are: beforeEnter , onEnter , beforeExit , onExit . All of the callbacks receive route , params , store , and queryParams as parameters. If the beforeExit or beforeEnter methods return false the navigation action will be prevented. - The current URL params and query params are accessible directly in the store store.router.params / store.router.queryParams so basically they're available everywhere without any additional wrapping or HOC. - Navigating to another route happens by calling the goTo method on the router store, and the changes in the url are reflected automatically. So for example you can call router.goTo(routes.book, {id:5, page:3}) and after the change is made in the store, the URL change will follow. You neve","default_branch":null,"files":null,"tree":[],"storefront":"/r/kitze","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/kitze/mobx-router/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}