Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getContainer() cannot be a parent component

See original GitHub issue

I wanted to use getContainer() in the SortableContainer HOC to set the scroll container to a parent component.

Unfortunately the getContainer() is called in SortableContainer.componentDidMount(), when the parent component is not yet mounted, so it returns undefined, and crashes.

Suggestion: allow specifying the container and scrollContainer separately in SortableContainer (adding a getScollContainer() function property would make the most sense; it would actually match the internal representation). Then lazily call getScrollContainer() when needed.

More information: basically the use case is the same as with useWindowAsScrollContainer, but where only part of the page scrolls.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

lbhbravecommented, Apr 19, 2019

Just to follow-up on this issue, the getContainer prop now accepts passing it a Promise that returns the container from a parent component

Would you mind give me a example how to use Promise to getContainer. I get the same problem as below and look for a solution. Thx very much

alex-vgcommented, Jun 8, 2017
  componentDidMount() {
    this.domNode = ReactDOM.findDOMNode(this);

  getContainer = () => this.props.scrollContainer || this.domNode;

render() {
    return (

Since I wanted to be able to set the container from the outside of the component, I added this.props.scrollContainer ||. Inside CustomSortableContainer, I resolve getContainer and just apply as a scrollContainer prop to a deeper component.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - JLabel - get parent panel? - Stack Overflow
getParent() it will return the panel the label is inside. ... boolean flag = true; Component parent = label; while (flag) { parent...
Read more >
Here is how to get ViewContainerRef before ... - InDepth.Dev
Suppose we have our parent App component and we want to add a child A component into the specific place in the template....
Read more >
Placing controls outside map container with Leaflet?
addTo(map); // Call the getContainer routine. var htmlObject = control.getContainer(); // Get the desired parent node. var a = document.
Read more >
Container (Java Platform SE 7 ) - Oracle Help Center
If the component is not an ancestor of this container and has a non-null parent, it is removed from its current parent before...
Read more >
tinymce.Editor | Docs
destroy(), Destroys the editor instance by removing all events, element references or other ... getContainer(), Returns the container element of the editor.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found