Skip to content

Stop returns undefined when using useSpring with callback function #637

@josephrexme

Description

@josephrexme

🐛 Bug Report

Undefined is being returned for stop - the third optional return, when a callback function is passed into useSpring

To Reproduce

I have the following:

 const [motion, setMotion, stopMotion] = useSpring(() => ({
   transform: 'scaleX(0)',
   config: { ...config.default, duration: 180000 }
 }));

with the jsx:

<Track>
  <animated.div style={motion} />
</Track>

Expected behavior

I expect that setMotion and stopMotion will be functions I can use to start and end my animations and indeed setMotion works as expected when called as:

setMotion({ transform: 'scaleX(1)' });

However stopMotion keeps returning undefined.
(A clear and concise description of what you expected to happen.)

Link to repro (highly encouraged)

Here's a reproduced demo
CodeSandbox demo

Environment

  • react-spring v8.0.4
  • react v16.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions