Coder Social home page Coder Social logo

Comments (5)

bvaughn avatar bvaughn commented on May 18, 2024 1

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.

bvaughn avatar bvaughn commented on May 18, 2024 1

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.

dartess avatar dartess commented on May 18, 2024

@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.

dartess avatar dartess commented on May 18, 2024

@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.

bvaughn avatar bvaughn commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.