All Projects β†’ MJez29 β†’ react-for

MJez29 / react-for

Licence: MIT license
A React component library to create loops in JSX

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-for

react-calculator
πŸ“ PWA React + Redux Calculator
Stars: ✭ 65 (+195.45%)
Mutual labels:  jsx
ink-box
Styled box component for Ink
Stars: ✭ 113 (+413.64%)
Mutual labels:  jsx
tung
A javascript library for rendering html
Stars: ✭ 29 (+31.82%)
Mutual labels:  jsx
TimerInterrupt
This library enables you to use Interrupt from Hardware Timers on an Arduino, such as Nano, UNO, Mega, etc. It now supports 16 ISR-based timers, while consuming only 1 hardware Timer. Timers' interval is very long (ulong millisecs). The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behavin…
Stars: ✭ 76 (+245.45%)
Mutual labels:  loop
ExtendScript-for-Visual-Studio-Code
Extension that adds Adobe ExtendScript support to Visual Studio Code
Stars: ✭ 29 (+31.82%)
Mutual labels:  jsx
adobe-discord-rpc
Discord Rich Presence extension for your adobe apps!
Stars: ✭ 383 (+1640.91%)
Mutual labels:  jsx
crud-app
❄️ A simple and beautiful CRUD application built with React.
Stars: ✭ 61 (+177.27%)
Mutual labels:  jsx
SRLCD
fast loop closure detection (online visual place recognition) via saliency re-identification IROS 2020
Stars: ✭ 78 (+254.55%)
Mutual labels:  loop
nornj
More exciting JS/JSX based on Template Engine, support control flow tags, custom directives, two-way binding, filters and custom operators.
Stars: ✭ 97 (+340.91%)
Mutual labels:  jsx
unplugin-icons
🀹 Access thousands of icons as components on-demand universally.
Stars: ✭ 2,064 (+9281.82%)
Mutual labels:  jsx
fjb
fast javascript bundler πŸ“¦
Stars: ✭ 103 (+368.18%)
Mutual labels:  jsx
goone
goone finds N+1 query in go
Stars: ✭ 41 (+86.36%)
Mutual labels:  loop
next-boilerplate
πŸ“ A modern universal boilerplate for React applications using Next.js.
Stars: ✭ 15 (-31.82%)
Mutual labels:  jsx
react-jsx-renderer
A React component for Rendering JSX
Stars: ✭ 43 (+95.45%)
Mutual labels:  jsx
ai-merge
Import your SVG, AI, EPS, and PDF files into a single Illustrator document.
Stars: ✭ 65 (+195.45%)
Mutual labels:  jsx
animate
πŸ‘Ύ Create and manage animation functions with AnimationFrame API.
Stars: ✭ 11 (-50%)
Mutual labels:  loop
BarterOnly
An ecommerce platform to buy or exchange items at your convenience
Stars: ✭ 16 (-27.27%)
Mutual labels:  jsx
javascript
Traveloka JavaScript style guide
Stars: ✭ 24 (+9.09%)
Mutual labels:  jsx
iwish
I wish that too!
Stars: ✭ 19 (-13.64%)
Mutual labels:  jsx
reacty yew
Generate Yew components from React components via Typescript type definitions
Stars: ✭ 46 (+109.09%)
Mutual labels:  jsx

React For

A React component library to create loops in JSX.

NPM Version NPM Downloads GitHub stars

Installation

$ npm install --save react-for

Usage

All components require that you pass in a function to be called each loop.

For Loop

The For component emulates a javascript for loop.

const arr = [];
for (let i = INITIAL_VALUE; TEST_EXPR; NEXT_OP) {
  const component = CODE_TO_CREATE_COMPONENT;
  arr.push(component);
}

Is equivalent to

import { For } from 'react-for';
<For start={INITIAL_VALUE} comparator={i => TEST_EXPR} next={i => NEXT_OP}>{
  (i) => {
    CODE_TO_CREATE_COMPONENT;
    return component;
  }
}</For>

For Of

The ForOf component emulates a for..of loop.

const data = [ 1, 2, 3 ];
const arr = [];
for (const value of data) {
  const component = CODE_TO_CREATE_COMPONENT;
  arr.push(component);
}

Is equivalent to

import { ForOf } from 'react-for';
const data = [ 1, 2, 3 ];
<ForOf data={data}>{
  (i) => {
    CODE_TO_CREATE_COMPONENT;
    return component;
  }
}</ForOf>

For In

The ForIn component emulates a for..in loop.

const data = [ 1, 2, 3 ];
const arr = [];
for (const value in data) {
  const component = CODE_TO_CREATE_COMPONENT;
  arr.push(component);
}

Is equivalent to

import { ForOf } from 'react-for';
const data = [ 1, 2, 3 ];
<ForIn data={data}>{
  (i) => {
    CODE_TO_CREATE_COMPONENT;
    return component;
  }
}</ForIn>

While

The While component emulates a while loop.

const arr = [];
while (TEST_EXPR) {
  const component = CODE_TO_CREATE_COMPONENT;
  arr.push(component);
}

Is equivalent to

import { While } from 'react-for';
const data = [ 1, 2, 3 ];
<While test={TEST_EXPR}>{
  (i) => {
    CODE_TO_CREATE_COMPONENT;
    return component;
  }
}</While>

Do While

The DoWhile component emulates a do-while loop.

const arr = [];
do {
  const component = CODE_TO_CREATE_COMPONENT;
  arr.push(component);
} while (TEST_EXPR)

Is equivalent to

import { DoWhile } from 'react-for';
const data = [ 1, 2, 3 ];
<DoWhile test={TEST_EXPR}>{
  (i) => {
    CODE_TO_CREATE_COMPONENT;
    return component;
  }
}</DoWhile>

Keying

In React, a key prop should be attached to all components being rendered from a list. The key should be a string that is unique among all components in the list.

// The following generates an ascii code table
<table>
  <tr>
    <th>Ascii Code</th>
    <th>Character</th>
  </tr>
  <For start={0} test={i => i < 256} next={i => i + 1}>{
    (i) => (
      <tr key={i}>
        <td>{i}</td>
        <td>{String.fromCharCode(i)}</td>
      </tr>
    )
  }</For>
</table>

Prop Aliasing

Currently the following prop aliases are supported. Create an issue to suggest others. The first prop of each row is the recommended alias and is used in all code examples.

Prop Type Aliases
Data data, from
Next next
Render children, render
Start start, begin
Test test, comparator, compare

Docs

Click to see full docs here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].