Skip to content

Floats can be cast to integers with useSpring #1461

@CodyJasonBennett

Description

@CodyJasonBennett

🐛 Bug Report

Stringified or literal floats are being cast to integers when they are only significant to one value via useSpring.

To Reproduce

The described problem is immediately visible on mount, with no interpolation being done.

Try interpolating between a float that holds significance to another that does not (defined by default). Then try having react-spring animate back to the latter value — it's then converted to an integer.

Expected behavior

Springs should respect the highest precision and/or keep the output as a float. I'm not sure if the former is a regression, but it isn't a nice pattern to see.

As it's unclear if this behavior is done intentionally, I'm keeping this as a potential bug.

Link to repro (highly encouraged)

Try clicking on the centered number to animate and play around with the values as I outlined above.

Reproduction - Workaround

Environment

  • react-spring v9.1.2
  • react v17.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corerelates to core classes // parts of the librarykind: bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions