Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not render the overlay element in OverlayTrigger #372

Open
oroce opened this issue Apr 4, 2018 · 0 comments
Open

Do not render the overlay element in OverlayTrigger #372

oroce opened this issue Apr 4, 2018 · 0 comments

Comments

@oroce
Copy link
Member

oroce commented Apr 4, 2018

The node passed in overlay prop to OverlayTrigger is rendered all the time. Which doesn't make sense. Real life example: if there's a notification icon in the header which triggers the notification popup to be shown (similarly to facebook) and there's an error in the popover the whole application will crash. Moreover it needs more resource to render that mostly not opened component.

So we shouldn't render the overlay element until the state becomes active.

Basically

render() {
  return (<div>
    { this.state.isActive && (this.props.overlay) }
  </div>)
}

The code where this should be added is here:

{ React.cloneElement(this.props.overlay, {
className: classNames(this.props.overlay.props.className, 'overlay'),
onClick: (e) => {
if (this.props.overlay.props.onClick) {
e.preventDefault();
this.props.overlay.props.onClick();
}
},
innerRef: (c) => (this.popper = findDOMNode(c))
}) }

Maybe to prevent breaking changes and there can be others who rely on this sideeffect, it would be wise to introduce a lazyRender prop and if that's true we should postpone all the rendering as we can. But performance wise and being mobile friendly I would definately make the lazyrendering default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant