Skip to content

Commit 169ea5c

Browse files
committed
Fix refs for React 16, update deps
1 parent 5af7a3b commit 169ea5c

File tree

3 files changed

+322
-111
lines changed

3 files changed

+322
-111
lines changed

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-css-transition-replace",
3-
"version": "2.2.1",
3+
"version": "2.2.2",
44
"description": "A React component to animate replacing one element with another.",
55
"main": "lib/ReactCSSTransitionReplace.js",
66
"repository": {
@@ -14,15 +14,15 @@
1414
"prepublish": "npm run build"
1515
},
1616
"dependencies": {
17-
"prop-types": "^15.5.6",
18-
"react-transition-group": "^1.1.1"
17+
"prop-types": "^15.6.0",
18+
"react-transition-group": "^1.2.1"
1919
},
2020
"peerDependencies": {
21-
"react": "^15.0.0",
22-
"react-dom": "^15.0.0"
21+
"react": "^15.0.0 || ^16.0.0",
22+
"react-dom": "^15.0.0 || ^16.0.0"
2323
},
2424
"devDependencies": {
25-
"babel-cli": "^6.24.1",
25+
"babel-cli": "^6.26.0",
2626
"babel-eslint": "^6.1.0",
2727
"babel-plugin-add-module-exports": "^0.2.1",
2828
"babel-plugin-check-es2015-constants": "^6.8.0",
@@ -31,15 +31,15 @@
3131
"babel-plugin-transform-decorators-legacy": "^1.3.4",
3232
"babel-plugin-transform-es2015-arrow-functions": "^6.8.0",
3333
"babel-plugin-transform-es2015-block-scoped-functions": "^6.8.0",
34-
"babel-plugin-transform-es2015-block-scoping": "^6.24.1",
34+
"babel-plugin-transform-es2015-block-scoping": "^6.26.0",
3535
"babel-plugin-transform-es2015-classes": "^6.24.1",
3636
"babel-plugin-transform-es2015-computed-properties": "^6.24.1",
3737
"babel-plugin-transform-es2015-destructuring": "^6.16.0",
3838
"babel-plugin-transform-es2015-duplicate-keys": "^6.24.1",
3939
"babel-plugin-transform-es2015-for-of": "^6.8.0",
4040
"babel-plugin-transform-es2015-function-name": "^6.24.1",
4141
"babel-plugin-transform-es2015-literals": "^6.8.0",
42-
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.1",
42+
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
4343
"babel-plugin-transform-es2015-object-super": "^6.24.1",
4444
"babel-plugin-transform-es2015-parameters": "^6.24.1",
4545
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
@@ -48,16 +48,16 @@
4848
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
4949
"babel-plugin-transform-es2015-typeof-symbol": "^6.8.0",
5050
"babel-plugin-transform-es2015-unicode-regex": "^6.24.1",
51-
"babel-plugin-transform-object-rest-spread": "^6.16.0",
51+
"babel-plugin-transform-object-rest-spread": "^6.26.0",
5252
"babel-plugin-transform-object-set-prototype-of-to-assign": "^6.8.0",
53-
"babel-plugin-transform-proto-to-assign": "^6.9.0",
53+
"babel-plugin-transform-proto-to-assign": "^6.26.0",
5454
"babel-plugin-transform-react-constant-elements": "^6.9.1",
55-
"babel-plugin-transform-react-display-name": "^6.8.0",
55+
"babel-plugin-transform-react-display-name": "^6.25.0",
5656
"babel-plugin-transform-react-inline-elements": "^6.8.0",
5757
"babel-plugin-transform-react-jsx": "^6.24.1",
5858
"babel-plugin-transform-react-pure-class-to-function": "^1.0.1",
59-
"babel-plugin-transform-react-remove-prop-types": "^0.2.9",
60-
"babel-polyfill": "^6.16.0",
59+
"babel-plugin-transform-react-remove-prop-types": "^0.4.9",
60+
"babel-polyfill": "^6.26.0",
6161
"babelify": "^7.3.0",
6262
"browser-sync": "^2.17.2",
6363
"browserify": "^13.1.0",
@@ -69,10 +69,10 @@
6969
"gulp-flatten": "^0.2.0",
7070
"gulp-notify": "^2.2.0",
7171
"lodash.assign": "^4.2.0",
72-
"react": "^15.3.2",
73-
"react-bootstrap": "^0.31.0",
74-
"react-dom": "^15.3.2",
75-
"rimraf": "^2.5.4",
72+
"react": "^16.0.0",
73+
"react-bootstrap": "^0.31.3",
74+
"react-dom": "^16.0.0",
75+
"rimraf": "^2.6.2",
7676
"vinyl-buffer": "^1.0.0",
7777
"vinyl-source-stream": "^1.1.0",
7878
"watchify": "^3.7.0"

src/ReactCSSTransitionReplace.jsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export default class ReactCSSTransitionReplace extends React.Component {
125125
// transitioned into existence. When another child is set for this component at the point
126126
// where only refs.next exists, we want to use the width/height of refs.next instead of
127127
// refs.curr.
128-
const ref = this.refs.curr || this.refs.next
128+
const ref = this.curr || this.next
129129

130130
// Set the next child to start the transition, and set the current height.
131131
this.setState({
@@ -163,7 +163,7 @@ export default class ReactCSSTransitionReplace extends React.Component {
163163
})
164164
}
165165

166-
const nextNode = ReactDOM.findDOMNode(this.refs.next)
166+
const nextNode = ReactDOM.findDOMNode(this.next)
167167
if (nextNode) {
168168
this.setState({
169169
activeHeightTransition: true,
@@ -182,7 +182,7 @@ export default class ReactCSSTransitionReplace extends React.Component {
182182
}
183183

184184
appearCurrent() {
185-
this.refs.curr.componentWillAppear(this._handleDoneAppearing)
185+
this.curr.componentWillAppear(this._handleDoneAppearing)
186186
this.isTransitioning = true
187187
}
188188

@@ -191,7 +191,7 @@ export default class ReactCSSTransitionReplace extends React.Component {
191191
}
192192

193193
enterNext() {
194-
this.refs.next.componentWillEnter(this._handleDoneEntering)
194+
this.next.componentWillEnter(this._handleDoneEntering)
195195
this.isTransitioning = true
196196
}
197197

@@ -211,7 +211,7 @@ export default class ReactCSSTransitionReplace extends React.Component {
211211
}
212212

213213
leaveCurrent() {
214-
this.refs.curr.componentWillLeave(this._handleDoneLeaving)
214+
this.curr.componentWillLeave(this._handleDoneLeaving)
215215
this.isTransitioning = true
216216
this.setState({isLeaving: true})
217217
}
@@ -267,6 +267,14 @@ export default class ReactCSSTransitionReplace extends React.Component {
267267
}, child)
268268
}
269269

270+
setCurrRef = (ref) => {
271+
this.curr = ref
272+
}
273+
274+
setNextRef = (ref) => {
275+
this.next = ref
276+
}
277+
270278
render() {
271279
const {currentChild, currentChildKey, nextChild, nextChildKey, height, width, isLeaving, activeHeightTransition} = this.state
272280
const childrenToRender = []
@@ -285,7 +293,7 @@ export default class ReactCSSTransitionReplace extends React.Component {
285293
{key: currentChildKey},
286294
this._wrapChild(
287295
typeof currentChild.type == 'string' ? currentChild : React.cloneElement(currentChild, {isLeaving}),
288-
{ref: 'curr'})
296+
{ref: this.setCurrRef})
289297
)
290298
)
291299
}
@@ -333,7 +341,7 @@ export default class ReactCSSTransitionReplace extends React.Component {
333341
},
334342
key: nextChildKey,
335343
},
336-
this._wrapChild(nextChild, {ref: 'next'})
344+
this._wrapChild(nextChild, {ref: this.setNextRef})
337345
)
338346
)
339347
}

0 commit comments

Comments
 (0)