Skip to content

Change how refs are set #13

@james2406

Description

@james2406

Hey, thanks for creating such a lightweight/performant library! I think this library could improve on its api slightly to make it easier to use in an application using refs. Instead of returning a ref as the first return value, it would be more flexible if it could be passed in as the first argument to useDimensions:

const containerRef = useRef(null);
const dimensions =  useDimensions(containerRef);

This would make it easier to work with other libraries, such as useScrolling:

const containerRef = useRef(null);
const dimensions =  useDimensions(containerRef);
const scrolling = useScrolling(containerRef);

I would be more than happy to make a PR for this change, however, I understand if you wouldn’t want to introduce this change as it would be breaking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions