Exercise 46 - React Animation Components
Exercise 46 - React Animation Components
Installing React-Animation-Components
Install react-animation-components into your React app as follows:
Adding Animations
Open HomeComponents.js and update as follows:
...
import { FadeTransform } from 'react-animation-components';
...
<FadeTransform
in
transformProps={{
exitTransform: 'scale(0.5) translateY(-50%)'
}}>
<Card>
<CardImg src={baseUrl + item.image} alt={item.name} />
<CardBody>
<CardTitle>{item.name}</CardTitle>
{item.designation ? <CardSubtitle>{item.designation}</CardSubtitle> : null }
<CardText>{item.description}</CardText>
</CardBody>
</Card>
</FadeTransform>
...
...
import { FadeTransform, Fade, Stagger } from 'react-animation-components';
1
...
<FadeTransform
in
transformProps={{
exitTransform: 'scale(0.5) translateY(-50%)'
}}>
<Card>
<CardImg top src={baseUrl + dish.image} alt={dish.name} />
<CardBody>
<CardTitle>{dish.name}</CardTitle>
<CardText>{dish.description}</CardText>
</CardBody>
</Card>
</FadeTransform>
...
<Stagger in>
{comments.map((comment) => {
return (
<Fade in>
<li key={comment.id}>
<p>{comment.comment}</p>
<p>-- {comment.author} , {new Intl.DateTimeFormat('en-US', { year: 'numeric', month: 'short', day: '2-
digit'}).format(new Date(Date.parse(comment.date)))}</p>
</li>
</Fade>
);
})}
</Stagger>
...
Save all the changes and do a Git commit with the message "React Animation Components".
Conclusions
In this exercise you saw yet another way of adding subtle animations using react-animation-
components.