universal-router v3.0.0 Release Notes

Release Date: 2017-03-25 // about 7 years ago
    • ⚡️ Update Router API (BREAKING CHANGE)
      import Router from 'universal-router'
      const router = new Router(routes, options)
      router.resolve({ path, ...context }) // => Promise<any>
    
      // previously
      import { resolve } from 'universal-router'
      resolve(routes, { path, ...context }) // => Promise<any>
    

    See #83 for more info and examples

    • 0️⃣ context.next() now iterates only child routes by default (BREAKING CHANGE) use context.next(true) to iterate through the all remaining routes
    • ✂ Remove babel-runtime dependency to decrease library size (BREAKING CHANGE) Now you need to care about these polyfills yourself:
    • ➕ Add support for URL Generation js import generateUrls from 'universal-router/generate-urls' const url = generateUrls(router) url(routeName, params) // => String
    • ➕ Add support for Dynamic Breadcrumbs, use context.route.parent to iterate
    • ➕ Add support for Declarative Routes, new Router(routes, { resolveRoute: customResolveRouteFn })
    • ➕ Add support for Base URL option, new Router(routes, { baseUrl: '/base' })
    • ➕ Add ability to specify custom context properties once, new Router(routes, { context: { ... } })
    • Rewrite matchRoute function without usage of generators to decrease amount of necessary polyfills
    • ✂ Remove usage of String.prototype.startsWith()
    • ➕ Add context.url with the original url passed to resolve method
    • ➕ Add context property to Route not found error