Skip to content

Clarification on nodeRef #623

Closed
Closed
@eps1lon

Description

@eps1lon

When changing key prop of Transition in a TransitionGroup a new nodeRef need to be provided to Transition with changed key prop (see test/CSSTransition-test.js).

-- https://reactcommunity.org/react-transition-group/transition

Could you clarify why and how we would accomplish this (the linked test doesn't use nodeRef)?

It sounds like useRef wouldn't work for that since that one never changes. Instead we'd have to do something like const nodeRef = React.useMemo(() => ({ current: null }), [key]);.

Isn't the point of a "ref" that you don't need to change it because the pointer (current) always points to the latest value?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions