On the initial render of a pane, we call registerPane(), passing in the various onResize handlers. The problem is that if these functions change on a subsequent render, the updated functions will be ignored. For example, I'm trying to keep track of whether or not one panel is "maximized":
But here isMaximized is always going to be false, because even though I pass in a new onResizeEnd handler every render, only the initial onResizeEnd is ever called.
A good way to work around this would be to store the onResizeEnd in a useRef inside of Pane. Something like:
then pass this ref in to registerPane(). The ref will be updated on every render, and whenever we need to call the callback we'll have access to the latest version.
On the initial render of a pane, we call registerPane(), passing in the various
onResize
handlers. The problem is that if these functions change on a subsequent render, the updated functions will be ignored. For example, I'm trying to keep track of whether or not one panel is "maximized":But here
isMaximized
is always going to be false, because even though I pass in a newonResizeEnd
handler every render, only the initialonResizeEnd
is ever called.A good way to work around this would be to store the
onResizeEnd
in a useRef inside of Pane. Something like:then pass this ref in to
registerPane()
. The ref will be updated on every render, and whenever we need to call the callback we'll have access to the latest version.