import { cloneElement, ReactElement } from 'react';

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