pmndrs / pmndrs/react-spring

[bug]: Different configs per property not possible in useTransition()

Open
#2,136 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: core kind: bug release: major
Dominant language
TypeScript
Stars
29.1k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

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.6.0

What's Wrong?

When using useTransition it does not seem to be possible to have different spring configs per property like stated in https://www.react-spring.dev/docs/advanced/config#config-per-springvalue .

To Reproduce

Consider this simple transition:

const transitions = useTransition(data, {
    from: { opacity: 0, y: 2 },
    enter: { opacity: 1, y: 0 },
    leave: { opacity: 0, y: -2 },
    config: (key) => {
        return key === 'y' config.wobbly : { duration: 600 };
    },
});

https://www.react-spring.dev/docs/advanced/config#config-per-springvalue states that a function-based config has access to the key of the animated property. In case of useTransition() the passed variable holds the value of data.

Expected Behaviour

We have access to the property key in function-based configs.

Link to repo

_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the useTransition implementation and the config-per-springvalue documentation linked in the report, using the @react-spring/three target and the shown property-based configuration. Reproduce the transition with separate opacity and y settings, then verify that the configuration callback receives the animated property key and that both configurations take effect.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, three.js, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.