Skip to content

Instantly share code, notes, and snippets.

@inPhoenix
Created December 8, 2018 09:19
Show Gist options
  • Save inPhoenix/bc2c52ddedd7ce50dab3fcc6ab268956 to your computer and use it in GitHub Desktop.
Save inPhoenix/bc2c52ddedd7ce50dab3fcc6ab268956 to your computer and use it in GitHub Desktop.
React Spring super simple example
import React, { Component } from 'react'
import { Spring } from 'react-spring'
class ShowHide extends Component {
state = {
opacity: 0
}
onHover = () => {
this.setState(prevState => ({
opacity: prevState.opacity === 0 ? 1 : 0
}))
}
render() {
return (
<Spring from={{ opacity: 0 }} to={{ opacity: this.state.opacity }}>
{props => (
<div style={props} onClick={this.onHover}>
Hide Me!
</div>
)}
</Spring>
)
}
}
export default ShowHide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment