Allow size override from props after resized
See original GitHub issueI’m storing the state of my interface in a MongoDB object, which makes it possible to update the look of several independent browser windows on fly (all changes in the layout are saved to that object using a Meteor method, then the updated data are pushed to all subscribed instances of the app).
This approach did not work well with SplitPane, so I had to write a small hack to make it work. The reason for the problem is in the way the component treats defaultSize and size.
Setting up size disables dragging and defaultSize is read only once and is ignored after resized becomes true. It would be nice if the component was tracking the changes in the defaultSize and was updating itself to it when this prop has changed.
Here is my current workaround (to help those who is facing something simiar):
export default class MyPage extends React.Component {
constructor(props) {
super(props);
this._handleSplitPaneOnDragFinished = this._handleSplitPaneOnDragFinished.bind(this);
}
_handleSplitPaneOnDragFinished() {
const splitPane = this.refs['splitPane'];
const draggedSize = splitPane.state.draggedSize;
updateInterfaceMongoDBObjectWithNewPaneSize(draggedSize);
// ↑ this is not the actual way of updating interface object, but you get the point
// ↓ this is what does the trick
splitPane.setState({
resized: false,
draggedSize: undefined,
});
}
render() {
// Assume that interface is that object from MongoDB that has describes the current layout
// (it is always up-to-date)
const interface = props.interface;
// part of return:
<SplitPane split="vertical" minSize={ 100 } maxSize={ 400 }
ref="splitPane"
defaultSize={ interface.paneSize }
onDragFinished={ this._handleSplitPaneOnDragFinished }
>
}
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (2 by maintainers)

Top Related StackOverflow Question
Hi @IanVS,
I haven’t used the component for a couple of months, so I can’t tell. I’ll try to let you know when this happens next time (this might be quite soon actually)!
Thanks for that PR!
Sure - I’ll try and take a look a later…