Skip to content

[bug]: View interpolation doesn't work with some "to" variables in coming up with a final transform #1912

@varunarora

Description

@varunarora

Which react-spring target are you using?

  • @react-spring/web
  • @react-spring/three
  • @react-spring/native
  • @react-spring/konva
  • @react-spring/zdog

What version of react-spring are you using?

9.4.5

What's Wrong?

I tried using the to spring "variables" named scale3dValue and translate3dY to use for interpolation to come up with a final transform value. It doesn't work. The value itself springs from start to finish, but it disrupts the creation of a final transform.

Changing it to less descriptive variables like o (described here: https://react-spring.io/basics#view-interpolation), xyz, a, b, etc. works. Why?


To Reproduce

const [props, api] = useSpring(() => ({
  from: {
    // Had this be 'a: 0', and every `scale3dValue` below replaced with `a`,
    // the transform would apply just fine.
    scale3dValue: 0,
  },
})

// Later, say in an event callback, particularly with the use of interpolation.
props.transform.set(
  props.scale3dValue.to(value => `scale3d(${value})`)
)

api.start({ scale3dValue: 1 })

/*
I'd imagine similar behavior from the following

return <animated.div
  style={{
    transform: scale3dValue.to(value => `scale3d(${value})`)
  }}
/>
*/

Expected Behaviour

The creation of the final transform value not be disrupted by what variable named are used, as long as they are not CSS style props.

Link to repo

https://codesandbox.io/s/focused-estrela-yy950s?file=/src/App.js

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