# react-render-helpers

> A series of helper functions to add inline control-flow logic in React render methods.

Latest version **1.2.0** (published 2019-05-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-render-helpers
pnpm add react-render-helpers
yarn add react-render-helpers
bun add react-render-helpers
```

## 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.2.0 |
| Published | 2019-05-29 |
| First published | 2017-08-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 148.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Jordan Hurt |
| Maintainers | jth0024 |
| Keywords | react, render, helpers, tools, logic |

## Links

- npm: https://www.npmjs.com/package/react-render-helpers
- Repository: https://github.com/jth0024/react-render-helpers
- Homepage: https://github.com/jth0024/react-render-helpers#readme
- Issues: https://github.com/jth0024/react-render-helpers/issues
- npm.io page: https://npm.io/package/react-render-helpers

## 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.2.0 (latest) — 2019-05-29
- 1.0.3 — 2018-08-01
- 1.0.2 — 2017-08-03
- 1.0.1 — 2017-08-02
- 1.0.0 — 2017-08-02

## README

# react-render-helpers

[![CircleCI](https://circleci.com/gh/jth0024/react-render-helpers/tree/master.svg?style=svg)](https://circleci.com/gh/jth0024/react-render-helpers/tree/master)

A collection of helpers for conditionally rendering components or elements in React.

- Supports both **JSX** and **Hyperscript** syntax.
- Supports **lazy evaluation** to avoid null reference errors.
- Support modularized imports to allow for tree-shaking.
- Provides **curried** helpers for easy partial application.


## Installation

```bash
yarn add react-render-helpers
```

## Documentation

### hideIf

```javascript
import h from 'react-hyperscript';
import { hideIf } from 'react-render-helpers';
// Or use modular imports
import hideIf from 'react-render-helpers/hideIf'

export default ({ isClosed }) => h('.window', {}, [
  hideIf(isClosed)(h('div', {}, 'Window is open!')),
  // Or provide a function for lazy evaluation
  hideIf(isClosed)(() => h('div', {}, 'Window is open!')),
]);
```


### showIf

```javascript
import h from 'react-hyperscript';
import { showIf } from 'react-render-helpers';
// Or use modular imports
import showIf from 'react-render-helpers/showIf'

export default ({ isClosed }) => h('.window', {}, [
  showIf(isClosed)(h('div', {}, 'Window is closed!')),
  // Or provide a function for lazy evaluation
  showIf(isClosed)(() => h('div', {}, 'Window is closed!')),
]);
```


### switchOn

```javascript
import h from 'react-hyperscript';
import { switchOn } from 'react-render-helpers';
// Or use modular imports
import switchOn from 'react-render-helpers/switchOn'

export default ({ color }) => h('.palette', {}, [
  switchOn(color)({
    blue: h('div.blue', { style: { color: 'blue' } }, 'Blue!'),
    red: h('div.red', { style: { color: 'red' } }, 'Red!'),
    defaultTo: h('div', {}, 'No color...'),
  }),
  // Or provide functions as values for lazy evaluation
  switchOn(color)({
    blue: () => h('div.blue', { style: { color: 'blue' } }, 'Blue!'),
    red: () => h('.red', { style: { color: 'red' } }, 'Red!'),
    defaultTo: () => h('div', {}, 'No color...') ,
  }),
]);
```

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