
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
if-else-react
Advanced tools
This
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
<div>
{isLoggedIn ? (
<span>
<Button onClick={this.handdleSettingsClick}>Account Settings</Button>
<Button onClick={this.handleLogoutClick}>Logout</Button>
</span>
) : (
<span>
<Button onClick={this.handleLoginClick}>Login</Button>
<Button onClick={this.handleSignUpClick}>Sign Up</Button>
</span>
)}
</div>
);
}
becomes this ✨
render() {
const isLoggedIn = this.state.isLoggedIn;
return (
<div>
<If condition={isLoggedIn}>
<Button onClick={this.handdleSettingsClick}>Account Settings</Button>
<Button onClick={this.handleLogoutClick}>Logout</Button>
<Else />
<Button onClick={this.handleLoginClick}>Login</Button>
<Button onClick={this.handleSignUpClick}>Sign Up</Button>
</If>
</div>
);
}
Install via npm:
$ npm install if-else-react --save
and then just import it in your app
import If, { Else } from 'if-else-react';
and use it like shown in the example above. done 🎉
If ComponentThe If Component is only rendering whats inside if the condition prop is true.
If there is a Else component as a direct children then all children components after the Else will be rendered if the condition is false.
| Prop | Type | Default | Required? |
|---|---|---|---|
| condition | boolean | undefined | no |
Else ComponentThe Else Component renders and does nothing by itself. But when used inside of a Ifthen it seperates what is rendered based on the condition passed into the If.
| Prop | Type | Default | Required? |
|---|---|---|---|
| - | - | - | - |
FAQs
small helper component for conditional rendering
We found that if-else-react 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.