SpringValue.map
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- react, typescript
- Domain
- frontend
Research direction
The issue names SpringValue and animated but does not identify files, tests, or a specific entry point. Start by locating those APIs and reviewing how dependent values are currently handled; done would require an agreed design and tests covering a mapped value such as converting 0 to a hidden display value.
Written by the indexing model from the issue text.
Description
Proposal
react-spring's desire to completely avoid rendering has been causing tons and tons of problems for me ever since I tried adopting it. The seemingly opaque SpringValue datatype can only be used in very specific places due to the way animated works. I can't do things like change display to none only when a spring value is 0 because my component does not get re-rendered. It's so annoying and restrictive and I have to spend hours with each component figuring out how to coax the behavior I want out of the spring.
Perhaps one way to help with this would be to introduce a map method on SpringValue which would return another SpringValue that depends on the first one, allowing me to insert it into the right slots to get animated to recognize it, but process the values that reach the DOM. This would allow me to do things like hide an element when it is not visible (visibility value is 0).
<Spring to={...}>
{({value}) =>
<animated.div style={{display: value.map(v => v === 0 ? 'none' : undefined)}}>...</animated.div>
}
</Spring>
This will solve some of the issues with the current system without react-spring having to move to another.
Rationale
The perfect solution that I have come up with is a component that re-renders every frame by using window.requestAnimationFrame and detecting when the spring values change. Of course, this is the exact OPPOSITE of what this library is designed to do, but - it solves every single problem I had with spring, and allows me to use the values however I like. I call it the SpringSolidifier because it turns the SpringValues into actual values that can be used. It uses a render prop to return the "solidified" values object. Additionally, it allows me to completely unmount the element when it is fully invisible. This is currently not possible with react-spring to my knowledge. Due to this, I'm no longer reliant on the quirks of animated - springs become usable anywhere in my application, for any purpose, even CSS properties or conditional rendering or what-have-you.
However, since that component is the complete opposite of what this library currently does, I think a map function would fit the project better. It would allow react-spring to keep the updates out of React, but also allow the consumers of the library to control those updates. Right now react-spring only has the former.
- Dominant language
- TypeScript
- Stars
- 29.3k
- Forks
- 1.2k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 17
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pmndrs/react-spring
-
template: bug
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
pmndrs/react-spring#2656 ·
Maintainers usually reply within 1 day
-
area: core kind: request
Difficulty 4/5 3-5 days Newbie friendliness 55/100
pmndrs/react-spring#2542 ·
Maintainers usually reply within 1 day
-
area: typescript kind: request release: major
Difficulty 4/5 3-5 days Newbie friendliness 52/100
pmndrs/react-spring#2541 · 1 comment ·
Maintainers usually reply within 1 day
-
release: major type: RFC
Difficulty 5/5 Over a week Newbie friendliness 35/100
pmndrs/react-spring#2522 · 1 comment ·
Maintainers usually reply within 1 day
-
[bug]: Tab crash with skipAnimation and loopPossibly taken @mrityunjay-pandey claimed this 43 days ago. Openarea: core kind: bug
Difficulty 3/5 1-2 days Newbie friendliness 52/100
pmndrs/react-spring#2409 ·
Maintainers usually reply within 1 day
All issues in pmndrs/react-spring
Similar issues
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 82/100
lingdojo/kana-dojo#34714 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
manaflow-ai/cmux#59692 ·
Maintainers usually reply within 1 day
-
Retire stale Python-parity labels in Rust ingress and auth testsPossibly taken @github-actions claimed this today. Openfactory factory:building factory:unowned ralph-status:in-progress via:opencode-free/hy4-flash-free
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
JoshCLWren/comic-pile#5874 · 2 comments ·
Maintainers usually reply within 1 day
-
area: community lane: free-agent priority: P1 roadmap type: task
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
velella-sh/offing#1046 ·
Maintainers usually reply within 1 day