Skip to content

How to use with props? #6

Description

@geohuz

The examples are all using const value, I'm not sure how to use it with props value? , eg:

const springs = createSpring({
   from: { x: props.x, y: props.y}
...

But then the animted.div doesn't get react anyway, any solution for this issue?

And here is my code snippet for using spring to show an dot animation on positions (passed by props.x, props.y):

function Dot(props) {
  const [local] = splitProps(props, ["x", "y"])

  const styles = createSpring({
    from: {
      x: local.x,
      y: local.y 
    },
    to: {
      x: local.x,
      y: local.y
    }
  })


  
  return (
    <>
      <animated.div
        style={{
          width: `20px`,
          height: `20px`,
          background: '#ff6d6d',
          "border-radius": '50%',
          ...styles()
        }}
      >
        <span>RID:{Math.random()}</span>
      </animated.div> 
    
    </>
  )
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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