SolidJSS
SolidJS3y ago
45 replies
akerbeltz

children.forEach typescript problem

I have this problem in the forEach with typescript.
Property 'forEach' does not exist on type 'ResolvedChildren'.
Property 'forEach' does not exist on type 'number'.ts(2339)

export interface PropsDl {
  children: JSX.Element;
}
const DescriptionList: Component<PropsDl> = (props) => {
  const c = children(() => props.children);

  createEffect(() => {
    c().forEach((item, i) => {
      if (i % 2 == 0) item.style = 'background-color:whitesmoke';
    });
  });

  return (
    <>
      <div class='dl'> {c()}</div>
    </>
  );
};
Was this page helpful?