diff --git a/src/CSSTransition.js b/src/CSSTransition.js
index 61592105..8fb69e19 100644
--- a/src/CSSTransition.js
+++ b/src/CSSTransition.js
@@ -190,7 +190,7 @@ class CSSTransition extends React.Component {
const { doneClassName } = this.getClassNames('enter');
if (type === 'appear' && phase === 'done' && doneClassName) {
- className += ` ${doneClassName}`;
+ className = className ? `${className} ${doneClassName}` : doneClassName;
}
// This is to force a repaint,
diff --git a/test/CSSTransition-test.js b/test/CSSTransition-test.js
index 9ec4672a..b5addcd9 100644
--- a/test/CSSTransition-test.js
+++ b/test/CSSTransition-test.js
@@ -203,34 +203,37 @@ describe('CSSTransition', () => {
expect(nodeRef.current.className).toBe('appear-test-enter-done');
});
- it('should not add undefined when appearDone is not defined', async () => {
- const nodeRef = React.createRef();
- let done = false;
- render(
- {
- expect(isAppearing).toEqual(true);
- expect(nodeRef.current.className).toEqual('appear-test');
- }}
- onEntered={(isAppearing) => {
- expect(isAppearing).toEqual(true);
- expect(nodeRef.current.className).toEqual('');
- done = true;
- }}
- >
-
-
- );
-
- await waitFor(() => {
- expect(done).toEqual(true);
- });
- });
+ it.each(['', 'enter-done'])(
+ 'should not add undefined when appearDone is omitted and enterDone is %s',
+ async (enterDone) => {
+ const nodeRef = React.createRef();
+ let done = false;
+ render(
+ {
+ expect(isAppearing).toEqual(true);
+ expect(nodeRef.current.className).toEqual('appear-test');
+ }}
+ onEntered={(isAppearing) => {
+ expect(isAppearing).toEqual(true);
+ expect(nodeRef.current.className).toEqual(enterDone);
+ done = true;
+ }}
+ >
+
+
+ );
+
+ await waitFor(() => {
+ expect(done).toEqual(true);
+ });
+ }
+ );
it('should not be appearing in normal enter mode', async () => {
let count = 0;