React-virtualized: Why is width required?

Created on 11 May 2016  路  3Comments  路  Source: bvaughn/react-virtualized

Why isn't the width prop optional? Shouldn't it just default to width: 100% and be an optional prop?

question

Most helpful comment

I see your point, and part of me agrees with you, but I still feel like it's an opinionated standpoint that adds an unnecessary constraint.

I can definitely see the benefits of using AutoSize for the height of a component, but for the width... I feel like the AutoSize HOC adds an unnecessary layer of complexity, not to mention the performance hit (which is especially true when working with low powered mobile devices)

All 3 comments

A width property is required because there is no HTML element resize event and so there's no straight forward, native way for an element to detect its own size (if it changes). I feel it's better for react-virtualized components to be _pure_ and _stupid_ about their sizes. If you want 100% width or height behavior, use the AutoSize HOC.

I see your point, and part of me agrees with you, but I still feel like it's an opinionated standpoint that adds an unnecessary constraint.

I can definitely see the benefits of using AutoSize for the height of a component, but for the width... I feel like the AutoSize HOC adds an unnecessary layer of complexity, not to mention the performance hit (which is especially true when working with low powered mobile devices)

You don't _have_ to use AutoSizer if you don't plan on dynamic a (changing at runtime) width. Just read the width in your wrapper component and pass it down to whatever react-virtualized component you're using.

It _is_ an opinionated standpoint but it provides the most flexibility to users. You can use a fixed-size, or AutoSizer, or your own lightweight wrapper. Should be pretty simple, no?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mccambridge picture mccambridge  路  3Comments

SBoudrias picture SBoudrias  路  3Comments

zllc picture zllc  路  3Comments

rodcorsi picture rodcorsi  路  3Comments

hyeminHwang picture hyeminHwang  路  3Comments