Skip to content

Commit e4332d0

Browse files
committed
Don't use create-react-context
1 parent d72883d commit e4332d0

File tree

4 files changed

+31
-19
lines changed

4 files changed

+31
-19
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"react-dom": ">=15.0.0"
5555
},
5656
"dependencies": {
57-
"create-react-context": "^0.2.3",
5857
"dom-helpers": "^3.3.1",
5958
"loose-envify": "^1.4.0",
6059
"prop-types": "^15.6.2",

src/Transition.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { polyfill } from 'react-lifecycles-compat'
55

66
import { timeoutsShape } from './utils/PropTypes'
77

8-
import { Provider as TransitionGroupContextProvider, withTransitionGroup } from './TransitionGroupContext'
8+
import { Provider as TransitionGroupContextProvider, withTransitionGroup, transitionGroupContextPropType } from './TransitionGroupContext'
99

1010
export const UNMOUNTED = 'unmounted'
1111
export const EXITED = 'exited'
@@ -516,9 +516,7 @@ TransitionWithContext.propTypes = {
516516

517517
Transition.propTypes = {
518518
...TransitionWithContext.propTypes,
519-
transitionGroup: PropTypes.shape({
520-
isMounting: PropTypes.bool.isRequired
521-
}),
519+
transitionGroup: transitionGroupContextPropType,
522520
}
523521

524522
TransitionWithContext.defaultProps = {

src/TransitionGroupContext.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
1+
import * as PropTypes from 'prop-types'
12
import React from 'react'
2-
import createReactContext from 'create-react-context'
33

4-
const { Provider, Consumer } = createReactContext(null)
4+
const TransitionGroupContext = React.createContext && React.createContext(null)
5+
6+
export const transitionGroupContextPropType = PropTypes.shape({
7+
isMounting: PropTypes.bool.isRequired
8+
})
9+
10+
const Consumer = (TransitionGroupContext && TransitionGroupContext.Consumer) || class Consumer extends React.Component {
11+
static contextTypes = {
12+
transitionGroup: PropTypes.object,
13+
}
14+
render() {
15+
return this.props.children(this.context.transitionGroup)
16+
}
17+
}
18+
19+
const Provider = (TransitionGroupContext && TransitionGroupContext.Provider) || class Provider extends React.Component {
20+
static childContextTypes = {
21+
transitionGroup: transitionGroupContextPropType,
22+
}
23+
static propTypes = {
24+
value: transitionGroupContextPropType
25+
}
26+
getChildContext() {
27+
return { transitionGroup: this.props.value }
28+
}
29+
render() { return this.props.children }
30+
}
531

632
export function withTransitionGroup(ComponentToWrap) {
733
return class WithTransitionGroup extends React.Component {

yarn.lock

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3700,13 +3700,6 @@ create-react-class@^15.6.2:
37003700
loose-envify "^1.3.1"
37013701
object-assign "^4.1.1"
37023702

3703-
create-react-context@^0.2.3:
3704-
version "0.2.3"
3705-
resolved "https://registry.yarnpkg.com/create-react-context/-/create-react-context-0.2.3.tgz#9ec140a6914a22ef04b8b09b7771de89567cb6f3"
3706-
dependencies:
3707-
fbjs "^0.8.0"
3708-
gud "^1.0.0"
3709-
37103703
cross-spawn@5.1.0, cross-spawn@^5.0.1:
37113704
version "5.1.0"
37123705
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
@@ -5117,7 +5110,7 @@ fb-watchman@^2.0.0:
51175110
dependencies:
51185111
bser "^2.0.0"
51195112

5120-
fbjs@^0.8.0, fbjs@^0.8.12, fbjs@^0.8.16, fbjs@^0.8.9:
5113+
fbjs@^0.8.12, fbjs@^0.8.16, fbjs@^0.8.9:
51215114
version "0.8.17"
51225115
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.17.tgz#c4d598ead6949112653d6588b01a5cdcd9f90fdd"
51235116
dependencies:
@@ -5689,10 +5682,6 @@ growly@^1.3.0:
56895682
version "1.3.0"
56905683
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
56915684

5692-
gud@^1.0.0:
5693-
version "1.0.0"
5694-
resolved "https://registry.yarnpkg.com/gud/-/gud-1.0.0.tgz#a489581b17e6a70beca9abe3ae57de7a499852c0"
5695-
56965685
gzip-size@3.0.0:
56975686
version "3.0.0"
56985687
resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-3.0.0.tgz#546188e9bdc337f673772f81660464b389dce520"

0 commit comments

Comments
 (0)