SolidJSS
SolidJSโ€ข8mo agoโ€ข
19 replies
Paul

How to create or clone a component and add props to it

I have this snippet in react:

const _children = Children.toArray(children);
  const items = _children.map((item: any, index) =>
    cloneElement(item, {
      unstyled,
      __align: align,
      __active:
        item.props?.active ||
        (reverseActive ? active! >= _children.length - index - 1 : active! >= index),
      __lineActive:
        item.props?.lineActive ||
        (reverseActive ? active! >= _children.length - index - 1 : active! - 1 >= index),
    })
  );


I've searched around this discord a lot and can't seem to find anything that directly answers the question.

How can I duplicate the above, i.e clone a component and inject props into it?

I've tried to use Dynamic but it just gives me an empty response back.

Thanks
Was this page helpful?