Skip to content

Commit a307a6d

Browse files
committed
Only apply isLeaving to children that are React components.
1 parent 936dd63 commit a307a6d

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
### v2.0.0 (11 September 2016)
22

33
* [ENHANCEMENT] Add support for IE<=11 (thanks @le0nik) (#22, #23)
4+
* [ENHANCEMENT] Provide an `isLeaving` prop on the current child component while it is leaving. (thanks @le0nik)
45
* [ENHANCEMENT] Add ability to provide custom `height` className (useful for `css-modules`) (thanks @le0nik) (#20, #21)
56
* [BUGFIX] Fix multiple remounts of children (thanks @le0nik) (#24)
67
* [BUGFIX] Allow the child, that is leaving, to be `null` (thanks @le0nik)

demo/components/ContentLong.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22

33

4-
function ContentLong(props) {
4+
function ContentLong({className}) {
55
return (
6-
<div {...props}>
6+
<div className={className}>
77
<b>Some longer content</b>
88
<p>
99
Suspendisse non ante dui. Phasellus tempor sem non cursus feugiat. Pellentesque quis justo neque. Proin est

demo/components/ContentShort.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22

33

4-
function ContentShort(props) {
4+
function ContentShort({className}) {
55
return (
6-
<div {...props}>
6+
<div className={className}>
77
<b>Some shorter content</b>
88
<p>
99
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce pulvinar pharetra magna ac rhoncus. Pellentesque

demo/components/Demo.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { Navbar, Nav, NavItem, Grid } from 'react-bootstrap';
3+
const NavbarBrand = Navbar.Brand;
34

45
import PageHead from './PageHead.jsx';
56
import ContentSwapper from './ContentSwapper.jsx';
@@ -28,7 +29,7 @@ class Demo extends React.Component {
2829
return (
2930
<div>
3031
<Navbar>
31-
<Navbar.Brand>ReactCSSTransitionReplace</Navbar.Brand>
32+
<NavbarBrand>ReactCSSTransitionReplace</NavbarBrand>
3233
<Nav right>
3334
<NavItem href="https://github.com/marnusw/react-css-transition-replace" target="_blank">GitHub</NavItem>
3435
</Nav>

src/ReactCSSTransitionReplace.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function createTransitionTimeoutPropValidator(transitionType) {
3030

3131
// If the duration isn't a number
3232
}
33-
else if (typeof props[timeoutPropName] !== 'number') {
33+
else if (typeof props[timeoutPropName] != 'number') {
3434
return new Error(timeoutPropName + ' must be a number (in milliseconds)');
3535
}
3636
}
@@ -219,7 +219,7 @@ export default class ReactCSSTransitionReplace extends React.Component {
219219
_wrapChild(child, moreProps) {
220220
let transitionName = this.props.transitionName;
221221

222-
if (typeof transitionName === 'object' && transitionName !== null) {
222+
if (typeof transitionName == 'object' && transitionName !== null) {
223223
transitionName = { ...transitionName };
224224
delete transitionName.height;
225225
}
@@ -253,16 +253,16 @@ export default class ReactCSSTransitionReplace extends React.Component {
253253
React.createElement(
254254
'span',
255255
{ key: currentChildKey },
256-
this._wrapChild(React.cloneElement(currentChild, { isLeaving }), {
257-
ref: 'curr'
258-
})
256+
this._wrapChild(
257+
typeof currentChild.type == 'string' ? currentChild : React.cloneElement(currentChild, { isLeaving }),
258+
{ref: 'curr'})
259259
)
260260
);
261261
}
262262

263263

264264
if (height !== null) {
265-
const heightClassName = (typeof transitionName === 'object' && transitionName !== null) ?
265+
const heightClassName = (typeof transitionName == 'object' && transitionName !== null) ?
266266
transitionName.height || '' :
267267
`${transitionName}-height`;
268268

0 commit comments

Comments
 (0)