question-mark
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.

widget lifecycle methods / accessing the div after it has been mounted

See original GitHub issue

👋 hello from plotly! we’re working on the next version of the Plotly Jupyter widget in https://github.com/plotly/plotly.py/pull/942

There are some methods in our JS library that require a mounted/attached div (e.g. to know the size of the mounted div). However, in the widgets render method, we only have access to the unmounted/unattached div.

Are there any component lifecycle methods or events that we can utilize to customize the behaviour of the widget after it has been mounted on the DOM? To start, we would use this behaviour to either resize our plot to fill the container or defer making the plot until the div has been attached.

Many thanks!

(cc @jmmease)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jonmmeasecommented, Jun 12, 2018

For some reason the after-show event, referenced by ipyleaflet in the code snippet above, wasn’t being triggered for me. But when I dumped out all of the events I got a before-attach event followed by an after-attach event. And the after-attach event is exactly what we needed.

Thanks!

0reactions
chriddypcommented, Jun 13, 2018

Many thanks everyone 🙇

Read more comments on GitHub >

github_iconTop Results From Across the Web

flutter: Get notified when `Element` is unmounted only ...
I am currently handling Element directly for my own purpose. My current environment does not allow me to use State .
Read more >
The Stateful Widget Lifecycle
When the object is inserted into the tree ( mounted property is set to true ), this method is automatically executed after the...
Read more >
Flutter Widgets lifecycle, widget tree and element tree.
The Flutter framework makes a request from the widget using createElement method and then mounts the element to the element tree. Each element...
Read more >
Flutter life cycle methods and UI widget communication
This method is the most important one. It is called after 'didChangeDependencies()'. The entire tree of widgets to be rendered relays on this ......
Read more >
StatefulWidget lifecycle
All widgets have a bool this.mounted property. It is turns true when the buildContext is assigned. It is an error to call setState...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found