# react-conditionalfragment

> React component that only renders its contents if it's showIf prop is true.

Latest version **1.0.1** (published 2022-09-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-conditionalfragment
pnpm add react-conditionalfragment
yarn add react-conditionalfragment
bun add react-conditionalfragment
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-09-27 |
| First published | 2020-07-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 9.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Scott Bamford |
| Maintainers | scottbamford |
| Keywords | typescript, react, condition, hide, declerative |

## Links

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

## Dependencies (2)

- [react](https://npm.io/package/react.md) ^16.12.0
- [tslib](https://npm.io/package/tslib.md) ^1.9.3

## 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.1 (latest) — 2022-09-27
- 1.0.0 — 2020-07-07

## README

# react-scrollto
React component that only renders its contents if it's showIf prop is true.

This is designed to make a more readable version of {condition? (<SomeComponentsHere>...</SomeCompnentsHere>): null} were its helpful,
but is not designed to replace that pattern altogether, in particular, that pattern is always better when an else or condition chaining is to be used.

## Installation

Install react-conditionalfragment locally within your project folder, like so:

```shell
npm install react-conditionalfragment
```

Or with yarn:

```shell
yarn add react-conditionalfragment
```

## Basic Usage

Wrap your optional components in a <ConditionalFragment showIf={...}> with showIf={} set to the condition to check before including the components.

### Typescript
```ts
import { ScrollTo } from 'react-conditionalfragment';

// Usage with children
<ConditionalFragment showIf={isOpen}>
    <YourComponentsHere />
    ...
</ConditionalFragment>

```

### Javascript
```js
import { ScrollTo } from 'react-conditionalfragment';

// Usage with children
<ConditionalFragment showIf={isOpen}>
    <YourComponentsHere />
    ...
</ConditionalFragment>
```

## Typescript
This package is written in typescript and comes with its own bindings.

## License

Licensed under the MIT license.

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