
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Maybe render a React component, maybe not š®
// Get it!
yarn add mayre
npm install --save mayre
While working with React you'll find yourself making conditionals components quite a lot of times. And they're always the same: a component which upon a set of conditions may render or just return null (or short-circuit it).
Here comes Mayre (Maybe render)! A very simple and super light (2kb)
component to tackle this issue from the jsx side.
Compatible with React, React-Native and ReactVR.
There are three props you can use: of, when and with.
<Mayre
of={MyComponent}
when={props.something > 10}
with={{ some: 'thing' }}
/>
Note that of can be a component instance or declaration. And when can be boolean
or a function.
<Mayre
of={<p>Something</p>}
when={() => checkWhatever()}
/>
But not only this! Conditional rendering isn't only about mount this component or not. We can also use Mayre to render either this element or the other.
<Mayre
of={<p>Either this</p>}
or={<p>Or this one</p>}
when={whateverCondition}
/>
If a with prop is provided it'll be applied to both of them. If you want to specify special props for each of them use orWith.
<Mayre
of={<p>Either this</p>}
or={<p>Or this one</p>}
when={whateverCondition}
with={{ appliedTo: 'of' }}
orWith={{ appliedTo: 'this will used by or element' }}
/>
Most of the times the component rendered by Mayre is a subset of a bigger one. Hence, it's using a selection of the parent props. That's why Mayre has a special syntax to pick the props you need to while passing them down.
<Mayre
of={MyComponent}
when={props.something > 10}
with={[props, 'thisProps', 'andThisOther']}
/>
Same can be applied for orWith attribute.
| Name | Required | Default | Type | Comment |
|---|---|---|---|---|
| of | Yes | - | func, element | The React component to be rendered |
| or | No | null | func, element | The React component rendered instead of of |
| when | No | false | bool, func | The render condition |
| with | No | {} | object, array | Props to be passed to of/or component |
| orWith | No | {} | object, array | Props to be passed to or component |
Stop doing this:
// no more dumb render methods pollution
const renderSomething = (canRender, propsFromParent) => {
if (!canRender) return null
return <Something {...propsFromParent} />
}
const Parent = (props) => (
<div>
{renderSomething(props.a === props.b, props)}
</div>
)
FAQs
Maybe render a React component, maybe not š®
We found that mayre 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
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

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.