Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
react-router-tabs
Advanced tools
Simple navigation tabs for React Router 4.
There are many plain React solutions for tabs that conditionally render content based on some "activeTab" state. In a React Router app it would be preferable to keep rendering logic consistent by only using <Route>
s. This library exports a simple wrapper component to turn any enclosing element into a path-aware navigation tab using React Router links.
<RoutedTabs>
compound component lets you set props for nested tabs (classnames, styles, path prefix, ...others)via yarn
$ yarn add react-router-tabs
or npm
$ npm install --save react-router-tabs
import React from 'react';
import { Route, Switch, Redirect } from 'react-router-dom';
import { RoutedTabs, NavTab } from 'react-router-tabs';
import { Admins, Moderators, Users } from './components';
// Using default styles:
import 'styles/react-router-tabs.css';
const UsersPage = ({ match }) => {
return (
<div>
<RoutedTabs startPathWith={match.path}>
<NavTab to="/admins">Admins</NavTab>
<NavTab to="/moderators">Moderators</NavTab>
<NavTab to="/users">Users</NavTab>
</RoutedTabs>
<Switch>
<Route exact path={`${match.path}`} render={() => <Redirect replace to={`${match.path}/admins`} />} />
<Route path={`${match.path}/admins`} component={Admins} />
<Route path={`${match.path}/moderators`} component={Moderators} />
<Route path={`${match.path}/users`} component={Users} />
</Switch>
</div>
);
};
export default UsersPage;
<RoutedTabs />
Compound component to set props on enclosing <NavTabs>
s.
(optional but recommended)
Prop | Type | Default | Description |
---|---|---|---|
startPathWith | string | empty | String to append to the start of every tab's path to simplify writing out full paths. In most cases this should be given props.match.path |
className | string | 'react-router-tabs' | Custom className for the enclosing <div> s |
style | string | react-router-tabs' | Custom inline styles for the enclosing <div> s |
tabClassName | string | 'react-router-tabs__tab' | Custom className to be provided to each tab |
activeTabClassName | string | 'active' | Custom activeClassName to be provided to each tab |
tabStyle | string | empty | Custom inline style to be provided to each tab |
activeTabStyle | string | empty | Custom inline style to be provided to each tab |
<NavTab />
Forked and adapted from React Router's <NavLink />
. More info on below props in the official React Router docs.
Prop | Type | Default | Description |
---|---|---|---|
to | string | required | Path to the route to be rendered |
replace | bool | true | Replace current browser path rather than adding to the history |
exact | bool | false | Require exact path match (won't work for nested routes) |
strict | bool | true | Trailing slash considered for path match |
disabled | bool | false | Sets disabled className/style and blocks onClick() |
className | string | 'react-router-tabs' | Custom className for this tab |
activeClassName | string | 'active' | Custom activeClassName for this tab |
style | string | empty | Custom inline style |
activeStyle | string | empty | Custom inline style when active |
Both components can take various classname and inline style props.
<RoutedTabs>
will provide tabClassName/activeTabClassName and tabStyle/activeTabStyle to any nested <NavTabs>
. Please see the API above for more detail.
If no classnames or styles are provided, the default classnames will be used. A default stylesheet is provided in this repo (CSS/SASS versions) and can be imported like below:
import 'node_modules/react-router-tabs/styles/react-router-tabs.css';
Note: the provided styles have not been tested.
Thanks to the React Router team. This module only exists to simplify one of a thousand use-cases for their great library.
Chace Stewart (chacestew@gmail.com)
MIT
[1.0.3] - 2017-12-30
RoutedTabs
updated to handle null children (when tabs are rendered conditionally).FAQs
Dead simple navigation tabs for React Router
The npm package react-router-tabs receives a total of 1,242 weekly downloads. As such, react-router-tabs popularity was classified as popular.
We found that react-router-tabs 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.