score:0

createportal receive a single react node, so you will need to wrap it inside another <></> (react.fragment):

this is createportal type:

export function createportal(
  children: reactnode,
  container: element,
  key?: null | string
): reactportal;

so you would need to change your code to:

<portal>
  <>
    <overlay />
    <modal
      padding={padding}
      width={width}
      height={height}
      radius={radius}
      overflowy={overflowy}
    >
      {children}
    </modal>
  </>
</portal>;

and in your portal.tsx

export const portal: react.functioncomponent<react.reactnode> = ({
  children
}) => {
  const el = document.getelementbyid("portal");
  if (el) return reactdom.createportal(children, el);
  return null;
};

working example:

edit agitated-microservice-8zsew


Related Query

More Query from same tag