React SplitView: Restore Layout #505
Unanswered
MidnightTinge
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using a SplitView in a react project and am having problems (de)serializing its width for persistence. This is a simple two-pane layout with a treeview on the left and a content pane on the right. In the onReady callback I am attaching an
onDidDimensionChange
handler to the treeview panel and this works perfectly for saving the panel's width. It's restoration that I am unable to do.I know that
layout
is not exported on the typescript type so maybe I went down the wrong rabbithole but digging through the source code it seems likelayout
is what I'm looking for. But when I uselayout()
on the panel within theonReady
callback there's no change, same withsetSize()
. Is there another way to do this in React?The following is a basic example of what I'm trying to do:
https://codesandbox.io/p/sandbox/cranky-austin-n6w96l?file=%2Fsrc%2FApp.tsx%3A30%2C21
If you open the codesandbox console (top-right of the preview window, lil terminal icon) you'll see that states are serialized correctly but just not being restored. The restoration logic is src/App.tsx line 29-34, you can swap which code block is commented to verify neither are working.
Beta Was this translation helpful? Give feedback.
All reactions