preact-compat icon indicating copy to clipboard operation
preact-compat copied to clipboard

componentDidMount is not fired for portals

Open 1999 opened this issue 7 years ago • 2 comments

I'm having a very awkward issue at the moment: my render() function returns a portal:

render() {
    const {
      children,
      overrideStyle = {},
    } = this.props;

    const portal = (
      <PortalContainer>
        <Text innerRef={this.textRef}>
          <Overlay style={overrideStyle}>
            <OverlayContent>
              {children}
            </OverlayContent>
          </Overlay>
        </Text>
      </PortalContainer>
    );

    return createPortal(portal, this.domNode);
  }

But when the component is rendered for the first time "render" is called, but "componentDidMount" doesn't get executed. On the second render everything works fine and component actually renders and componentDidMount is fired. Is here anything I can help?

1999 avatar Nov 10 '18 11:11 1999

@1999 - componentDidMount of the parent component, or the child?

developit avatar Dec 18 '18 18:12 developit

componentDidMount() of the component which has this render implementation that I described above.

1999 avatar Dec 20 '18 06:12 1999