From 1736aa9b373642bff3d0c30fc4fa6ea73dd90e72 Mon Sep 17 00:00:00 2001 From: Julian Grinblat Date: Wed, 6 May 2020 05:37:19 +0900 Subject: [PATCH 1/3] Support SSR --- src/Transition.js | 2 +- test/SSR-test.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/SSR-test.js diff --git a/src/Transition.js b/src/Transition.js index 116852e3..a9160035 100644 --- a/src/Transition.js +++ b/src/Transition.js @@ -394,7 +394,7 @@ Transition.propTypes = { * (see * [test/CSSTransition-test.js](https://github.com/reactjs/react-transition-group/blob/13435f897b3ab71f6e19d724f145596f5910581c/test/CSSTransition-test.js#L362-L437)). */ - nodeRef: PropTypes.shape({ current: PropTypes.instanceOf(Element) }), + nodeRef: PropTypes.shape({ current: PropTypes.instanceOf(typeof Element === 'undefined' ? function() {} : Element) }), /** * A `function` child can be used instead of a React element. This function is diff --git a/test/SSR-test.js b/test/SSR-test.js new file mode 100644 index 00000000..629acacd --- /dev/null +++ b/test/SSR-test.js @@ -0,0 +1,10 @@ +/** + * @jest-environment node + */ + +// test that import does not crash +import * as ReactTransitionGroup from '../src'; // eslint-disable-line no-unused-vars + +describe('SSR', () => { + it('should import react-transition-group in node env', () => {}); +}); From 2d1d4a589289cc6cb961d1cbaf8cb9cfc8425327 Mon Sep 17 00:00:00 2001 From: Jason Quense Date: Wed, 6 May 2020 10:40:27 -0400 Subject: [PATCH 2/3] Update src/Transition.js --- src/Transition.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Transition.js b/src/Transition.js index a9160035..7d9974d3 100644 --- a/src/Transition.js +++ b/src/Transition.js @@ -394,7 +394,11 @@ Transition.propTypes = { * (see * [test/CSSTransition-test.js](https://github.com/reactjs/react-transition-group/blob/13435f897b3ab71f6e19d724f145596f5910581c/test/CSSTransition-test.js#L362-L437)). */ - nodeRef: PropTypes.shape({ current: PropTypes.instanceOf(typeof Element === 'undefined' ? function() {} : Element) }), + nodeRef: PropTypes.shape({ + current: typeof Element === 'undefined' + ? PropTypes.any + : PropTypes.instanceOf(Element) + }), /** * A `function` child can be used instead of a React element. This function is From 2173bd90e0a09e02a502d8c69bf9511561afa6e0 Mon Sep 17 00:00:00 2001 From: Jason Quense Date: Wed, 6 May 2020 10:45:18 -0400 Subject: [PATCH 3/3] rm whitespace --- src/Transition.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Transition.js b/src/Transition.js index 7d9974d3..4fdbb15e 100644 --- a/src/Transition.js +++ b/src/Transition.js @@ -394,10 +394,10 @@ Transition.propTypes = { * (see * [test/CSSTransition-test.js](https://github.com/reactjs/react-transition-group/blob/13435f897b3ab71f6e19d724f145596f5910581c/test/CSSTransition-test.js#L362-L437)). */ - nodeRef: PropTypes.shape({ - current: typeof Element === 'undefined' + nodeRef: PropTypes.shape({ + current: typeof Element === 'undefined' ? PropTypes.any - : PropTypes.instanceOf(Element) + : PropTypes.instanceOf(Element) }), /**