Skip to content

Commit

Permalink
perf: don't reflow when there's no class to add
Browse files Browse the repository at this point in the history
Avoid an unnecessary reflow in the CSSTransition component if the class
name is falsy.
  • Loading branch information
michaelkix authored and silvenon committed Jun 13, 2018
1 parent 84af1ee commit d7b898d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/CSSTransition.js
Expand Up @@ -210,10 +210,12 @@ class CSSTransition extends React.Component {
reflowAndAddClass(node, className) {
// This is for to force a repaint,
// which is necessary in order to transition styles when adding a class name.
/* eslint-disable no-unused-expressions */
node && node.scrollTop;
/* eslint-enable no-unused-expressions */
addClass(node, className);
if (className) {
/* eslint-disable no-unused-expressions */
node && node.scrollTop;
/* eslint-enable no-unused-expressions */
addClass(node, className);
}
}

render() {
Expand Down

0 comments on commit d7b898d

Please sign in to comment.