
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
react-pathfy
Advanced tools
A very simple to install and use router tool for React and ReactNative
Probably the simplest router for React applications you will find.
npm i --save react-pathfy
To use React-Pathfy you have to set its routing elements as parents of the other elements in your application.
React-Pathfy has two routing elements Root
and Path
. Root
must be the
top most element in your elements tree. It receives Path
elements as children.
Path
elements may contain other Path
.
import React, { Component } from 'react';
import { Root, Path } from 'react-pathfy';
import MyComponent from './components/MyComponent';
import NotFound from './components/NotFound';
class App extends Component {
render() {
return (
<Root mode='browser'>
<Path origin="/hello" component={ <h1>Hello World</h1> } />
<Path origin="/some">
<Path origin="/path" component={ MyComponent } />
</Path>
<Path notFound={ true } component={ NotFound } />
</Root>
);
}
}
ReactDOM.render(<App />, document.getElementById('root'));
Defines the root of all paths.
mode: the mode React-Pathfy must use. The available options are browser,
hash and memory. You should use the memory
mode when you are developing a
ReactNative app or an application that doesn't rely on URLs. Defaults to browser.
Defines each path of an application.
Every path must have a component associated. Path
elements can be nested.
The inner elements will be passed as children to their parents. All Path
elements
in a path tree will receive the pathfy
props.
origin: the URL or key of a path. The URLs are combined if the Path
elements
are nested.
component: the component to be rendered.
notFound: A boolean value that defines a path to be used when no other paths respond to a request.
Defines a link element that changes the current path.
import { Link } from 'react-pathfy';
render(){
return (
<Link to={ '/payment' } state={ {type: 'credit-card'} } />
)
}
to: the URL or key of the target path.
state: the data to be passed to the rendered component
The origin defines the URL pattern or the key of the path. When the path responds to a URL, wildcards can be used to capture parameters.
/something/:parameter1
/something/:parameter1/(:parameter2)
In the first example above, :parameter1 defines a mandatory parameter. In the second example, (:parameter2) defines an optional parameter.
All origin parameters can be accessed by props.pathfy.params
When a component is rendered it receives a pathfy
props that has relevant resources
to be used.
action: The action that drove to that path. The possible values are INITIAL
,
PUSH
, POP
, REPLACE
state: The data passed when using the Link element.
origin: the current origin.
history: the global active history object.
params: the parameters in the URL.
query: an object representing the query string.
It is the most important dependency of React-Pathfy. Check the docs at https://www.npmjs.com/package/history
You can require the active history object from the react-pathfy module and use it, for example, in a Redux reducer.
import { history } from 'react-pathfy'
To change the current path you would use as following:
history.push('/some-path')
FAQs
A very simple to install and use router tool for React and ReactNative
We found that react-pathfy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.