react-spring

React Spring - Animate element between renders

不想你离开。 提交于 2021-01-28 09:10:39
问题 I'm trying to get my head over React Spring. So I have some boxes, which I need to filter by an active index, and the idea is to animate the boxes rendering, but I'm only having an animation when the component renders the first time. This is what I have so far: import React from "react"; import ReactDOM from "react-dom"; import styled from "@emotion/styled"; import { useTransition, animated } from "react-spring"; import "./styles.css"; const Header = styled.div` display: flex; justify-content

React-Spring useTransition shuffles my list items around

徘徊边缘 提交于 2021-01-27 08:11:05
问题 I have a list of labels that I render with a React-Spring Transition. The idea is that you can add items and if you have more than 5, a "Show more" button will appear. Pressing this button toggles wether you're showing all of the labels or just the first five. The problem is when I pass from "Showing more" to "Showing less". I noticed that before my items were hidden, all of them but the first moved to the beggining of the list, generating a weird effect where you can see the first labels

How to test a react component which uses react-spring?

回眸只為那壹抹淺笑 提交于 2019-12-11 15:28:12
问题 I'm trying to test my SpringComponent. This component uses react-spring for animations. When I run my test I get the following error: "Jest encountered an unexpected token". If I comment my Spring code the error disappears and my test passes. This is the testing code: import React from "react"; import SpringComponent from "../components/SpringComponent"; test('renders without crashing', () => { expect(true).toBeTruthy(); }); And the SpringComponent code: import React from "react"; import

React-spring animation only works at first render

本秂侑毒 提交于 2019-12-11 07:22:45
问题 I try to animate new entries in an array as they appear with react-spring It works quite fine at the first render but then doesn't animate when updated Here's a code sandbox where I reproduced the issue with an interval : https://codesandbox.io/s/01672okvpl import React from "react"; import ReactDOM from "react-dom"; import { Transition, animated, config } from "react-spring"; import "./styles.css"; class App extends React.Component { state = { fake: ["a", "b", "c", "d", "e", "f"] };