Skip to content

Simpler hook-only API without rendering a component? #1042

@ellatrix

Description

@ellatrix

Issue: 🚀 Feature Proposal

Thank you for this amazing animation library!

I've been wondering if there's any way for the animated component to be avoided at all by passing the ref directly to useSpring(s). As far as I understand, the animated component is used only so that there is access to the ref (to directly set styles) and otherwise props are just passed down, but maybe I'm missing something here.

Motivation

We'd like to create a hook that would contain useSpring that has access to the ref.

Example

What I'm proposing would be this:

const ref = useRef();
useSpring( { opacity: ..., target: ref } );

return <div ref={ ref } { ...otherProps } />;

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: requestNew feature or request that should be actioned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions