{"size": 768, "ext": "js", "max_stars_repo_path": "packages/core/__tests__/integration/TestAutoIdRecycle/ListComponet/index.js", "max_stars_repo_name": "t83714/fractal-component", "max_stars_repo_stars_event_min_datetime": "2018-09-20T07:15:11.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-08T11:54:33.000Z", "max_issues_repo_path": "packages/core/__tests__/integration/TestAutoIdRecycle/ListComponet/index.js", "max_issues_repo_name": "t83714/fractal-component", "max_issues_repo_issues_event_min_datetime": "2019-04-20T12:31:51.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-27T12:50:10.000Z", "max_forks_repo_path": "packages/core/__tests__/integration/TestAutoIdRecycle/ListComponet/index.js", "max_forks_repo_name": "t83714/fractal-component", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 16, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 25.6, "max_line_length": 66, "alphanum_fraction": 0.6002604167}
import React from "react";
import { useComponentManager } from "fractal-component";
import * as actionTypes from "./actions/types";
import ItemComponent from "../ItemComponent";

const reducer = (state, action) => {
    switch (action.type) {
        case actionTypes.SET_DATA:
            return action.payload;
        default:
            return state;
    }
};

const ListComponent = props => {
    const [state] = useComponentManager(props, {
        namespace: "io.github.t83714/ListComponent",
        initState: [],
        actionTypes,
        reducer
    });

    const items = state
        .map((v, idx) => (v ? <ItemComponent key={idx} /> : null))
        .filter(e => (e ? true : false));
    return <div>{items}</div>;
};

export default ListComponent;
