An open API service indexing awesome lists of open source software.

https://github.com/delpikye-v/react-loop

React wrapper loop. Simple and easy to use
https://github.com/delpikye-v/react-loop

loops react-for-each react-loop

Last synced: 4 months ago
JSON representation

React wrapper loop. Simple and easy to use

Awesome Lists containing this project

README

          


react-loop-z


NPM Package Β·
Live Example


[![NPM](https://img.shields.io/npm/v/react-loop-z.svg)](https://www.npmjs.com/package/react-loop-z)
![Downloads](https://img.shields.io/npm/dt/react-loop-z.svg)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

---

## πŸ“– Description
`react-loop-z` is a **React wrapper for looping** data structures.
It provides simple, clean, and declarative components for rendering arrays, objects, maps, sets, and conditional loops.

---

## πŸ“¦ Installation

```bash
npm install react-loop-z
# or
yarn add react-loop-z
```

---

## πŸš€ Usage

### Available Components
- **For** – iterate over arrays
- **Do** – do...while loop (⚠️ careful with infinite loops)
- **While** – while loop (⚠️ careful with infinite loops)
- **MapLoop** – iterate over `Map`
- **SetLoop** – iterate over `Set`
- **ObjectLoop** – iterate over object keys/values

---

### πŸ” For
```tsx
import { For } from "react-loop-z";

(
Hello, {item}
)}
/>

/>
```

---

### πŸ”‚ Do
```tsx
import { Do } from "react-loop-z";

let param = 0;

param < 2}
render={(index) => {
param++;
return Hello, {index};
}}
/>
```

---

### πŸ”„ While
```tsx
import { While } from "react-loop-z";

let param = 0;

param++ < 2}
render={(index) => (
Hello, {index}
)}
/>
```

---

### πŸ—ΊοΈ MapLoop
```tsx
import { MapLoop } from "react-loop-z";

const map = new Map([
["delpikye", "freelance"],
["hello", "world"],
]);

(

{key} - {value}

)}
/>
```

---

### 🧩 SetLoop
```tsx
import { SetLoop } from "react-loop-z";

const set = new Set(["foo", "bar"]);

(
{item}
)}
/>
```

---

### πŸ—‚οΈ ObjectLoop
```tsx
import { ObjectLoop } from "react-loop-z";

const obj = {
foo: "bar",
hello: "world",
};

(

{key} - {value}

)}
/>

// If `render` is undefined, it will display the object’s value by default
```

---

## ⚠️ Notes
- `Do` and `While` may create **infinite loops** if the condition never becomes false.
Always ensure you update state/variables properly inside the loop.

---

## πŸ“„ License
[MIT](https://mit-license.org/) Β© [DelpiK](https://github.com/delpik)