
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
react-guards
Advanced tools
Read this in other languages: [简体中文](https://github.com/wsafight/react-guards/blob/main/README.zh-CN.md)
Read this in other languages: 简体中文
The guard component can control whether the component can be displayed according to the permissions.
| Property | Description | Type | Default |
|---|---|---|---|
| target | target value | string|string[]|Promise|() => Promise | null |
| current | current value | string|string[]|'*' | null |
| errComponent | Display component on error | ReactComponent | null |
| loadingComponent | Display component on load | ReactComponent | null |
| Name | Description | Type |
|---|---|---|
| setGlobalCurrent | Set global current, do not pass current value by default use globalCurrent | (current: string | string[]) => void |
| canPassGuard | Determine whether it can pass the guard based on the passed data | ({target, current}) => Promise |
npm install react-guards
or
yarn add react-guards
import {ReactGuards} from 'react-guards'
// Show components without passing any data
<ReactGuards>
213
<div>324</div>
<button onClick={() => alert(0)}>213213</button>
</ReactGuards>
import {ReactGuards} from 'react-guards'
// none
<ReactGuards target='213' current='22'>
213
<div>324</div>
<button onClick={() => alert(0)}>213213</button>
</ReactGuards>
// show
<ReactGuards target='213' current='22,213'>
213
<div>324</div>
<button onClick={() => alert(0)}>213213</button>
</ReactGuards>
// none
<ReactGuards target='213' current={['22']}>
213
<div>324</div>
<button onClick={() => alert(0)}>213213</button>
</ReactGuards>
// show
<ReactGuards target='213' current={['22', '213']}>
213
<div>324</div>
<button onClick={() => alert(0)}>213213</button>
</ReactGuards>
// none
<ReactGuards target={Promise.resolve(false)} current='22,213'>
213
<div>324</div>
<button onClick={() => alert(0)}>213213</button>
</ReactGuards>
// show
<ReactGuards target={Promise.resolve(true)} current='22,213'>
213
<div>324</div>
<button onClick={() => alert(0)}>213213</button>
</ReactGuards>
// show
<ReactGuards target={(current) => Promise.resolve(true)} current='22,213'>
213
<div>324</div>
<button onClick={() => alert(0)}>213213</button>
</ReactGuards>
import { ReactGuards, setGlobalCurrent as setGlobalCurrentForReactGuard } from 'react-guards'
setGlobalCurrentForReactGuard('22,213')
// show
<ReactGuards target='22'>
213
<div>324</div>
<button onClick={() => alert(0)}>213213</button>
</ReactGuards>
import { ReactGuards, setGlobalCurrent as setGlobalCurrentForReactGuard } from 'react-guards'
const waitThenError = (): Promise<boolean> => {
return new Promise(resolve => {
setTimeout(() => {
resolve(false)
}, 2000);
})
}
const Load = () => <div>Loading</div>
const Error = () => <div>Error</div>
<ReactGuards target={waitThenError} errComponent={Error} loadingComponent={Load}>
213
<div>324</div>
<button onClick={() => alert(0)}>213213</button>
</ReactGuards>
FAQs
Read this in other languages: [简体中文](https://github.com/wsafight/react-guards/blob/main/README.zh-CN.md)
The npm package react-guards receives a total of 12 weekly downloads. As such, react-guards popularity was classified as not popular.
We found that react-guards 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.