portal icon indicating copy to clipboard operation
portal copied to clipboard

[BUG] Rendering in non browser environment (JSDOM)

Open pbrzosko opened this issue 1 year ago • 0 comments

When I am using portal component in a non browser environment, element in here is null:

const [ele] = React.useState(() => {
    if (!canUseDom()) {
      return null;
    }

And then this code fails because ele is null:

function cleanup() {
    ele.parentElement?.removeChild(ele);

    appendedRef.current = false;
  }

pbrzosko avatar Jul 03 '24 11:07 pbrzosko