Giter VIP home page Giter VIP logo

Comments (2)

rob2d avatar rob2d commented on May 27, 2024

Somehow missed this issue and was not using React for quite some time at a previous employer. Though always open if someone pushes a proposed fix even if I don't have the focus/time at the moment. This should be addressed now that I am a good place to update this lib and work on React applications again for these updates to make sense as a time investment.

For first issue:

You cannot call useViewportSizes with no parameters, you get a compilation error.

This should be addressed with an update tonight or tomorrow.

For the second issue:

const [vpW, vpH, updateVpSizes] = useViewportSizes(); doSomething(vpW, vpH); // ignore updateVpSizes return; // Error will result because updateVpSizes is unused

You should be able to destructure this as const [vpw, vpH] = useViewportSizes(); without TS complaining as standard practice if you do not need to invoke updateVpSizes().

For further context of source of issues: to preserve the minimum possible file size without compilation this was written in JS by hand (not usual for me) and d.ts is a little interesting; turns out you can override export default just by providing multiple defs -- very non-standard in either JS or TS outside of d.ts modules, but necessary since Type Inference/Control Flow is limited with types only annotated.

Considering how late this is I would not blame you if you've moved on to using another lib, but would like to comment in case it is useful for anyone else or if you find a need for this library again and thanks for reporting this. Going forward I will be sure to vet TS use-cases now that I have had much more experience and a bit more free time.

from use-viewport-sizes.

rob2d avatar rob2d commented on May 27, 2024

Working example on 0.5.1-beta.1 with Typescript project (also demo'ing destructure without triggering TS error) can be found @ https://codesandbox.io/s/tender-dirac-hgd6fe

from use-viewport-sizes.

Related Issues (10)

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.