npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@talend/router-bridge

v2.2.0

Published

Bridge on top of cmf-router or react-router v5 + connected-react-router

Downloads

239

Readme

@talend/router-bridge

This router-bridge aims to have a layer on top of router and redux connecter router actions. So libraries can support both cmf-router and future react-router v5 stack for

  • route definitions
  • redux action for redirection

Router components

React-router v5 support nested route definitions, but not v3 used by cmf-router v3.

The library need to duplicate the route mapping

  • cmf-router: based on settings
  • react-router v5: Route component

CMF-router mode Applications with cmf-router will only use the route definition from settings

React-router v5 mode Applications with react-router v5 will use the router-bridge routing definition that is a layer on top of react-router v5

@talend/router-bridge stays on top of react-router-dom. It serves react-router v5 components if it is loaded. Otherwise, nothing is rendered. So those route mapping can be used safely, they just won't set anything with cmf-router.

import { Switch, Route } from '@talend/router-bridge';

export function Home() {
    return (
        <>
			<Route path="/datasets" component={DatasetList} />
			<Switch>
				<Route path="/datasets/add" component={AddDatasetForm} />
				<Route path="/dataset/:id" component={DatasetDetails} />
			</Switch>
		</>
    )
}

Redux redirection action

@talend/router-bridge tries to stick to connected-react-router push/replace api. But with cmf-router, we need to pass a type, so we introduced a third argument, not available in connected-react-router functions.

| Argument | Type | Description | | ----------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------- | | url | string | The url to redirect to. | | historyState? | object | This state will be pushed to history state. | | customBaseAction? | object | cmf-router doesn't put an action type. This can be used to set one. In cmf-router mode, this will be spread into the resulting action. |

@talend/router-bridge redirect to cmf or connected-react-router action depending of the loaded library

The push/replace bridge will either

  • call connected-react-router push/replace if it is loaded
  • create an action for cmf-router otherwise
import { push, replace } from '@talend/router-bridge';

function redirectActionCreator() {
    return push('/home', null, { type: 'REDIRECT_TO_HOME' });
}