Skip to content

Require a ref param instead of returning a new ref? #35

@lederer

Description

@lederer

Is your feature request related to a problem? Please describe.
The current hook API returns a ref that the consumer must attach to the element. If the consumer also has their own ref, they need to merge the refs manually, which can be unwieldy.

Describe the solution you'd like
An alternative approach is to require that the consumer create their own ref and pass it into the hook.

// defaults
const ref = useRef();
const [isMounted, show, hide] = useShowtime(ref);
// with settings
const ref = useRef();
const [isMounted, show, hide] = useShowtime(ref, "rise");

See https://twitter.com/buildsghost/status/1338951882052567041 for some discussion.

Additional context
Unclear if we should do this. We need to evaluate pros and cons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions