Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

362
Views
React-grid-layout: How to improve widthProvider() HOC?

Please look at the below code snippet, specially the commented part. This is copied from React-grid-layout gitHub widthProvider() page.
Ref: https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/components/WidthProvider.jsx [Line:66-67]

My Question: How to implement this resize event in React.js?

I am creating a dashboard where I can open a popup menu to add/remove the grid-items. After adding the enough grids to overflow the height, scrollbarY appears which overlaps the grid-item.

I want to recalculate the width on addition of scrollbar.

Documentation also suggests to use other WidthProvider HOC if you need more sophisticated logic.
Ref: https://github.com/react-grid-layout/react-grid-layout#providing-grid-width

Thank you!

componentDidMount() {
      this.mounted = true;
      window.addEventListener("resize", this.onWindowResize);
      // Call to properly set the breakpoint and resize the elements.
      // Note that if you're doing a full-width element, this can get a little wonky if a scrollbar
      // appears because of the grid. In that case, fire your own resize event, or set `overflow: scroll` on your body.
      this.onWindowResize();
    }

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!