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.

Allow size override from props after resized

See original GitHub issue

I’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:open
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kachkaevcommented, Nov 17, 2016

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!

1reaction
tomkpcommented, Aug 1, 2016

Sure - I’ll try and take a look a later…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rerender view on browser resize with React - Stack Overflow
Your render() function should be a pure function of props and state. In your case you should save the new size in the...
Read more >
Render on Window Resize in React - Pluralsight
To show the width and height of a window and have the component render when this is changed, we first need to store...
Read more >
Apply overrides to instances - Components - Figma Help Center
You can apply the following overrides: Change text properties, including font, weight, size, line height, letter spacing, and resizing; Change the fill or ......
Read more >
resize - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
The element displays a mechanism for allowing the user to resize it, ... You may override this behavior with the resize property.
Read more >
react-resizable - npm
If a width or height is passed to <ResizableBox> 's style prop, it will be ignored as it is required for internal function....
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