File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,9 @@ export function ContextProvider(name) {
43
43
} ,
44
44
45
45
componentDidUpdate ( ) {
46
+ const nextValue = this . getChildContext ( ) [ name ]
46
47
this [ listenersKey ] . forEach ( listener =>
47
- listener ( this [ eventIndexKey ] )
48
+ listener ( this [ eventIndexKey ] , nextValue )
48
49
)
49
50
} ,
50
51
@@ -111,8 +112,12 @@ export function ContextSubscriber(name) {
111
112
this [ unsubscribeKey ] = null
112
113
} ,
113
114
114
- [ handleContextUpdateKey ] ( eventIndex ) {
115
+ [ handleContextUpdateKey ] ( eventIndex , nextValue ) {
115
116
if ( eventIndex !== this . state [ lastRenderedEventIndexKey ] ) {
117
+ if ( this . context [ name ] !== nextValue ) {
118
+ // React uses a stale value so we update it manually.
119
+ this . context [ name ] = nextValue
120
+ }
116
121
this . setState ( { [ lastRenderedEventIndexKey ] : eventIndex } )
117
122
}
118
123
}
You can’t perform that action at this time.
0 commit comments