Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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.0 - 1.0.1] - 2017-11-16
FAQs
Dead simple navigation tabs for React Router
The npm package react-router-tabs receives a total of 1,579 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.