
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
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.
react-control-flow-components
Advanced tools
Control flow components for React to make writing JSX more natural.
import React from 'react';
import { Case, ForEach, If, Switch } from 'react-control-flow-components';
<If test={ condition }>
<span>Only if true</span>
</If>
<Switch test={ condition }>
<Case value="first">
<span>If condition matches 'first'</span>
</Case>
<Case value="second">
<span>If condition matches 'second'</span>
</Case>
</Switch>
<ForEach items={ data }
component={ DataView } />
Install with npm or yarn
npm install --save react-control-flow-components
<If /><If test={ condition }>
<span>Only if true</span>
</If>
| Prop | Type | Notes |
|---|---|---|
test | Boolean | The expression to evaluate. Contents are rendered if the expression evaluates to truthy. |
Note that children are evaluated by React before being passed to <If /> so if a variable within the test may be null or undefined, you'l need to check that before accessing the variable in a way that would generate an error.
<Switch /><Switch test={ condition }>
<Case value="first">
<span>If condition matches 'first'</span>
</Case>
<Case value="second">
<span>If condition matches 'second'</span>
</Case>
</Switch>
| Component | Prop | Type | Notes |
|---|---|---|---|
<Switch /> | test | any | The expression to check each case against. |
<Case /> | value | any | The value to compare against test. |
The first matching case is rendered. If multiple cases match, only the first is rendered and and error is reported to the console.
<ForEach /><ForEach items={ data }
component={ DataView }
as="item"
spread
keyGen={(item, index) => index}
rest="wahtever I want" />
| Prop | Type | Notes |
|---|---|---|
items | any[] | Array of items to pass to the child components |
component | React component | The component that will be used to render each item in the items array. |
as | string | Optional. Specifies the name of the prop used to pass item to the rendered component. Default is item. |
spread | Boolean | Optional. When specified, instead of the item being passed as a single prop to the rendered component, each entry within the item is passed as a separate prop, similar to <Component {...item} />. Note as and spread are mutually exclusive. |
keyGen | string or function | Optional. Control over the key for each created child. If a string is passed, then it is assumed to be a property of each item. If a function is passed, it is called for each item with the item and index as arguments and is expected to return a uniue key. |
| rest | any | Any other props provided to <ForEach /> are passed through to each component instances as-is. |
See the unit tests under tests folder for many usage examples.
FAQs
Control flow components for React
The npm package react-control-flow-components receives a total of 4 weekly downloads. As such, react-control-flow-components popularity was classified as not popular.
We found that react-control-flow-components 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.

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.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.