# renderif

> Render. If.

Latest version **1.0.0** (published 2017-07-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install renderif
pnpm add renderif
yarn add renderif
bun add renderif
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-07-01 |
| First published | 2017-06-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Donavon West |
| Maintainers | donavon |
| Keywords | react, render, component, loop |

## Links

- npm: https://www.npmjs.com/package/renderif
- Repository: https://github.com/donavon/renderif
- Homepage: https://github.com/donavon/renderif#readme
- Issues: https://github.com/donavon/renderif/issues
- npm.io page: https://npm.io/package/renderif

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-07-01
- 1.0.0-beta.3 — 2017-07-01
- 1.0.0-beta.2 — 2017-07-01
- 1.0.0-beta.1 — 2017-07-01
- 0.1.0 — 2017-06-30

## README

# renderif

Render. If. The world's simplest React component.

## Installation

Let's quickly get this out of the way. How do I get your aweome code?

```sh
$ npm i --save renderif
```

## What problem does it solve?

With `renderif` you can stay within JSX without context switching.

```html
<div>
  <Render if={true}>
    <div>This will render</div>
  </Render>

  <Render if={false}>
    <div>This will NOT</div>
  </Render>
</div>
```

OK, so you would never actually code with boolean literals like that, but you get the picture.

Here is more of a real life example:

```html
<div>
  <Render if={loading}>
    <LoadingOverlay />
  </Render>
  <div>Rest of my component here</div>
</div>
```

## if/then/else? Sure, why not?

`renderif` also supports the more concise `if`/`then` and the `if`/`then`/`else` syntax shown below.
Note that in this pattern, `children` is unused.

```html
<div>
  <Render if={true} then={
    <div>This will render</div>
  }/>
  <div>Rest of my component here</div>
</div>
```

```html
<div>
  <Render if={true} then={
    <div>This will render</div>
  } else={
    <div>This will NOT</div>
  }/>
  <div>Rest of my component here</div>
</div>
```

## Live Example

You can see a live example running here on [codesandbox](https://codesandbox.io/s/BBlw3ML7Q).

---
_Source: https://npm.io/package/renderif · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
