File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -281,7 +281,9 @@ describe('reactTreeWalker', () => {
281281
282282 describe ( 'react' , ( ) => {
283283 it ( 'supports new context API' , ( ) => {
284- const { Provider, Consumer } = React . createContext ( )
284+ const { Provider, Consumer } = React . createContext ( {
285+ handler : io => io ,
286+ } )
285287
286288 class SomeInstance extends React . Component {
287289 render ( ) {
@@ -292,9 +294,9 @@ describe('reactTreeWalker', () => {
292294 const tree = (
293295 < Provider value = { { message : 'This is a provider message' } } >
294296 < Consumer >
295- { ( { message } ) => (
297+ { ( { message, handler } ) => (
296298 < strong >
297- < i > { message } </ i >
299+ < i > { ` ${ message } : ${ handler } ` } </ i >
298300 </ strong >
299301 ) }
300302 </ Consumer >
@@ -311,7 +313,7 @@ describe('reactTreeWalker', () => {
311313 elements . pop ( ) // Pop the div element
312314 elements . pop ( ) // Pop the class instance
313315 expect ( elements . pop ( ) ) . toBe ( 'Next' )
314- expect ( elements . pop ( ) ) . toBe ( 'This is a provider message' )
316+ expect ( elements . pop ( ) ) . toBe ( 'This is a provider message: io => io ' )
315317 } )
316318 } )
317319
Original file line number Diff line number Diff line change @@ -116,11 +116,14 @@ export default function reactTreeWalker(
116116 if ( currentElement . type ) {
117117 if ( currentElement . type . _context ) {
118118 // eslint-disable-next-line no-param-reassign
119- currentElement . type . _context . currentValue = currentElement . props . value
119+ currentElement . type . _context . _currentValue = {
120+ ...currentElement . type . _context . _currentValue ,
121+ ...currentElement . props . value ,
122+ }
120123 }
121124 if ( currentElement . type . Provider && currentElement . type . Consumer ) {
122125 const el = currentElement . props . children (
123- currentElement . type . Provider . _context . currentValue ,
126+ currentElement . type . Provider . _context . _currentValue ,
124127 )
125128 return recursive ( el )
126129 }
You can’t perform that action at this time.
0 commit comments