import { cloneElement, ReactElement } from 'react';

export default function ArrayConvertToObj(
    obj: Object,
    nextChildren: ReactElement[],
    callback: (child: any) => void,
): void {
    Object.values(nextChildren).forEach(
        (child: JSX.Element) =>
            (obj[child.key] = cloneElement(child, {
                ...child.props,
                endLifetime: callback.bind(null, child),
            })),
    );
}
