react - ReactJS Animations - react js - reactjs
What is Animation in reactjs?
- The ReactTransitionGroup add-on component is a low-level API for animation, and ReactCSSTransitionGroup is an add-on component for easily implementing basic CSS animations and transitions.
learn reactjs tutorials - appearence in reactjs animation
- reactjs example - react tutorial - reactjs - react
Follow these steps
Install React CSS Transitions Group
- React add-on is used for creating basic CSS transitions and animations.
- We will install it from command prompt window
Add CSS file
- create new folder css and file style.css inside. To be able to use it in our app, we need to link it to the head element in index.html.
Article tag : react , react native , react js tutorial , create react app , react tutorial , learn react
Appear Animation
- create basic React component.
- The ReactCSSTransitionGroupelement will be used as a wrapper of the component we want to animate.you can see it is
- using transitionAppear and transitionAppearTimeout while transitionEnter and transitionLeave are false.
App.jsx
main.js
- The CSS animation is very simple.
css/style.css
Article tag : react , react native , react js tutorial , create react app , react tutorial , learn react
Output:
- Once we start the app, our element will fade in.
learn reactjs tutorials - appearence in reactjs animation
- reactjs example - react tutorial - reactjs - react
Article tag : react , react native , react js tutorial , create react app , react tutorial , learn react
Enter and Leave Animations
- It can be used when we want to add or remove elements from the list.
App.jsx
main.js
css/style.css
Article tag : react , react native , react js tutorial , create react app , react tutorial , learn react
Output:
- When we start the app and click Add Item button, the prompt will appear.
learn reactjs tutorials -add items in reactjs animation
- reactjs example - react tutorial - reactjs - react
- Once we enter the name and press OK, the new element will fade in.
learn reactjs tutorials - new element in reactjs animation
- reactjs example - react tutorial - reactjs - react
- Now we can delete some of the items (Item 3...) by clicking on it. This item will fade out from the list.
learn reactjs tutorials - delete item in reactjs animation