@jfdi/react-utils-for

For is what loops should always have been in React.

Usage no npm install needed!

<script type="module">
  import jfdiReactUtilsFor from 'https://cdn.skypack.dev/@jfdi/react-utils-for';
</script>

README

For

For is what loops should always have been in React.

Install

npm install --save @jfdi/react-utils-for

Example

import React, { useState } from "react";
import ReactDOM from "react-dom";
import { For } from "@jfdi/react-utils-for";

const App = () => {
    const testItems = [{text: "test1"},{text: "test2"}];
    return (
        <For each={testItems}>{(item, index) => (
            <div key={`${item.text}${index}`}>{item.text}</div>
        )}</For>
    );
};
ReactDOM.render(<App />, document.getElementById("root"));