How to use the universal-router.match function in universal-router

To help you get started, we’ve selected a few universal-router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cassioscabral / rateissuesfront / src / client.js View on Github external
const removeHistoryListener = history.listen(location => {
    currentLocation = location
    match(routes, {
      path: location.pathname,
      query: location.query,
      state: location.state,
      context,
      render: render.bind(undefined, container, location.state, {store})
    }).catch(err => console.error(err)) // eslint-disable-line no-console
  })
github cassioscabral / rateissuesfront / src / server.js View on Github external
store.dispatch(setRuntimeVariable({
      name: 'initialNow',
      value: Date.now()
    }))

    store.dispatch(setRuntimeVariable({
      name: 'availableLocales',
      value: locales
    }))

    await store.dispatch(setLocale({
      locale
    }))

    await match(routes, {
      path: req.path,
      query: req.query,
      context: {
        store,
        insertCss: (...styles) => { styles.forEach(style => css.push(style._getCss())) }, // eslint-disable-line no-underscore-dangle
        setTitle: value => (data.title = value),
        setMeta: (key, value) => (data[key] = value)
      },
      render (component, status = 200) {
        css = []
        statusCode = status

        // Fire all componentWill... hooks
        data.body = ReactDOM.renderToString({ component })

        // If you have async actions, wait for store when stabilizes here.
github nightwolfz / inferno-starter / src / shared / router.js View on Github external
export default (routes, context, location) => {
    return match(routes(context), location).then(renderProps => {
        //context.router = history
        if (process.env.BROWSER && firstRender) {
            firstRender = false
            return renderProps.component
        }
        return fetchData(renderProps, context).then(() => renderProps.component)
    })
}

universal-router

Isomorphic router for JavaScript web applications

MIT
Latest version published 10 months ago

Package Health Score

73 / 100
Full package analysis