Comments (5)
This is a duplicate of issue #45
Sorry for the inconvenience, but the new Size
type is more accurate type than was there prior– as both width
and height
params are conditional based on the disableWidth
and disableHeight
props. (I don't know of a better way to model this with TypeScript. Maybe some kind of generic?)
For now, I'd recommend just casting the type.
from react-virtualized-auto-sizer.
Feel free to share what you're referring to- regarding the functional exploration. Not sure what to make of your comment without any code to reference
from react-virtualized-auto-sizer.
@bvaughn yes, this can be solved with generics and overloads, but TypeScript does not support class overloading, only functions. I tried writing function declarations (if your component were a function), and they work fine - depending on the settings of disableWidth
and disableHeight
, the correct types for Size. width
and Size. height
come.
I tried to rewrite the component to a function, but judging by the tests, there are unnecessary calls to some functions (although they look logical, on the contrary, I'm surprised that they are not in the current implementation).
from react-virtualized-auto-sizer.
@bvaughn sure: https://github.com/dartess/react-virtualized-auto-sizer/commits/fc
Tests are simply copied (replaced imports)
I tried to rewrite the component without changing the logic, but apparently I did not take into account some difference in the behavior of functional and class components, and the test results are different.
from react-virtualized-auto-sizer.
Gotcha.
Migrating to a function component would be nice.
Didn't look too close at this. Looks like your useEffect
is missing some dependencies in the array. Should be possible to do a rewrite though, but it would be a backwards breaking change (because of hooks APIs) so it would require a major bump.
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
- Types of disableHeight and disableWidth are incorrect HOT 6
- 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.