Skip to content

Commit d7b898d

Browse files
michaelkixsilvenon
authored andcommitted
perf: don't reflow when there's no class to add
Avoid an unnecessary reflow in the CSSTransition component if the class name is falsy.
1 parent 84af1ee commit d7b898d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/CSSTransition.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,12 @@ class CSSTransition extends React.Component {
210210
reflowAndAddClass(node, className) {
211211
// This is for to force a repaint,
212212
// which is necessary in order to transition styles when adding a class name.
213-
/* eslint-disable no-unused-expressions */
214-
node && node.scrollTop;
215-
/* eslint-enable no-unused-expressions */
216-
addClass(node, className);
213+
if (className) {
214+
/* eslint-disable no-unused-expressions */
215+
node && node.scrollTop;
216+
/* eslint-enable no-unused-expressions */
217+
addClass(node, className);
218+
}
217219
}
218220

219221
render() {

0 commit comments

Comments
 (0)