Comments (6)
They are booleans but that does not mean that all props combinations are valid. For example, this would not be valid and is something TypeScript should warn about:
<AutoSizer
disableHeight={toggle}
onResize={({ height }) => {
// ...
}
/>
I would argue just set these props as booleans
This caused confusion before (or maybe more accurately, it didn't catch incorrect combinations like the one I mentioned above) and people complained about it, so now the types are more restrictive.
If this is a problem for your specific case, you can always tell TypeScript to ignore (and/or cast the type).
from react-virtualized-auto-sizer.
+1
from react-virtualized-auto-sizer.
The types were chosen very intentionally to prevent bad combinations of params (e.g. an onResize
callback that tries to access height
even though the component has been configured to disableHeight
)
I chose not to support a resizer that had both height and width disabled because that seems pointless. If you'd like to make an argument for why that should be supported, I'll consider it.
from react-virtualized-auto-sizer.
I think my main issue with the current approach, is that it's now impossible to programmatically toggle disableHeight
or disableWidth
with a boolean, i.e.
let toggle: boolean = false;
if (some condition) toggle = true;
return (
<AutoSizer disableHeight={toggle}>
// Type 'boolean' is not assignable to type 'false'.
I would argue just set these props as booleans, and leave it to the user to determine which combination of height and width disabled they want. There can be use cases like ours, where we do sometimes need both to be disabled, depending on the layout we're going for.
Also your documentation states that both these props are booleans, which (going on TypeScript types at least) isn't right. If you decide not to change this, can you at least update the docs to make it clear how this works without having to dig into the code please?
from react-virtualized-auto-sizer.
Ok thanks for explaining and getting back to me so quickly @bvaughn. I'll just tell TypeScript to ignore for our use case and close this issue!
from react-virtualized-auto-sizer.
No problem ๐
from react-virtualized-auto-sizer.
Related Issues (20)
- AutoSizer cannot be used as a JSX component typescript error HOT 4
- Reporting an integer size when the available space has decimals HOT 6
- "react-virtualized-auto-sizer ๆฐ็ๆฌ้ๅคๆธฒๆๅญ็ปไปถ๏ผๅ antd tabs ๅฒ็ช HOT 2
- API change in return type HOT 2
- Args is type `any` in latest version (1.0.18) HOT 23
- "Can't perform a React state update on an unmounted component" console error HOT 5
- 1.0.19 does not render anything HOT 1
- Is it possible to test AutoSizer-powered components in unit tests? HOT 8
- TypeScript: Incorrect typing of AutoSize height and width HOT 2
- Typings for conditional `disableHeight` and `disableWidth` HOT 2
- 'AutoSizer' cannot be used as a JSX component. HOT 1
- Is it possible to render content inside auto sizer callback on server? HOT 1
- AutoSizer not rendering initially with consistent height for fixed height components HOT 2
- Recurrence of old Resizer bug (Width/Height NaN for AutoSizer #150) HOT 4
- Version 1.0.22 is breaking all of our unit tests HOT 50
- Autosizer component does not accept any refs. HOT 1
- bailoutOnChildren causes remounts HOT 3
- Access the component height from outside the component to pass to itemSize HOT 13
- Autosizer sets state in componentDidMount causing a nested update HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-virtualized-auto-sizer.