Skip to content

Instantly share code, notes, and snippets.

@jmn
Created February 4, 2019 13:16
Show Gist options
  • Save jmn/b642cd0261b88003e5d385d9ffc5b4f3 to your computer and use it in GitHub Desktop.
Save jmn/b642cd0261b88003e5d385d9ffc5b4f3 to your computer and use it in GitHub Desktop.
Why does this not animate?
import React, { Component } from "react";
import { Transition } from "react-spring";
import "./App.css";
class App extends Component {
state = {
items: [1, 2, 3],
toggleDiv: false
};
render() {
return (
<div id="root">
<header className="App-header">
<div>Hello</div>
<Transition
items={this.state.items}
keys={item => item}
from={{ transform: "translate3d(0,-40px,0)" }}
enter={{ transform: "translate3d(0,0px,0)" }}
leave={{ transform: "translate3d(0,-40px,0)" }}
trail={20}
>
{item =>
this.state.toggleDiv && (props => <div style={props}>{item}</div>)
}
</Transition>
<button onClick={() => this.setState({ toggleDiv: true })}>
Hej
</button>
</header>
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment