Not getting the update list of panels when calling api.panels #386
-
Describe the bug I may be doing something wrong, but it seems that api.panels do not return the updated value. https://codesandbox.io/s/green-tree-2xzdl7?file=/src/app.tsx Steps to reproduce the behavior:
Expected behavior |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Thanks for the description. Take a read of the below and let me know what you think. I believe the issue here is just a little confusion in terms of how the I think one important note is that the From the Line 67 Line 73 As an example I added another button Call api.panels where you can the list of panels being displayed in the console in this forked sandbox. If what you wanted to do was listen to the number of panels changing there is an event for this on the |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for the information, I really appreciate! |
Beta Was this translation helpful? Give feedback.
Thanks for the description.
Take a read of the below and let me know what you think. I believe the issue here is just a little confusion in terms of how the
api
object works.I think one important note is that the
api
object is not React state. In fact, dockview is mostly written in pure TypeScript for maximum performance and it's internal state has no tie to React. Theapi
object returned is a once-created (singleton) object that can be referenced for the duration of the components lifecycle and there are a number of events attached to theapi
to listen to state changes such as adding and removing panels.From the
onReady
event you can access and maintain a reference to theapi
from wher…