@@ -37,6 +37,31 @@ const defaultCreateTransition = transition => {
3737
3838const defaultRunTransition = ( ) => { } ;
3939
40+ const defaultRenderScreen = (
41+ ScreenComponent , transition , transitions , transitioningFromState ,
42+ transitioningToState , transitionRouteKey , navigation , ref , behindScreenStyles ,
43+ ) => (
44+ < Animated . View
45+ style = { [ { ...StyleSheet . absoluteFillObject } , behindScreenStyles ] }
46+ pointerEvents = { 'auto' }
47+ >
48+ < ScreenComponent
49+ transition = { transition }
50+ transitions = { transitions }
51+ transitioningFromState = { transitioningFromState }
52+ transitioningToState = { transitioningToState }
53+ transitionRouteKey = { transitionRouteKey }
54+ navigation = { navigation }
55+ transitionRef = { ref }
56+ />
57+ </ Animated . View >
58+ ) ;
59+
60+ const defaultRenderContainer = ( transitionRouteKey , transitions , navigation ,
61+ transitioningFromState , transitioningToState , transitionRefs , children ) => (
62+ < React . Fragment > { children } </ React . Fragment >
63+ ) ;
64+
4065const getStateForNavChange = ( props , state ) => {
4166 // by this point we know the nav state has changed and it is safe to provide a new state. static
4267 // getDerivedStateFromProps will never interrupt a transition (when there is state.transitionRouteKey),
@@ -208,6 +233,7 @@ export class Transitioner extends React.Component {
208233 navState,
209234 descriptors,
210235 } = this . state ;
236+ const { navigation } = this . props ;
211237 const mainRouteKeys = navState . routes . map ( r => r . key ) ;
212238 let routeKeys = mainRouteKeys ;
213239
@@ -219,9 +245,15 @@ export class Transitioner extends React.Component {
219245 }
220246 }
221247
248+ // Use render container function from last route descriptor
249+ const renderContainerFunc = descriptors [ transitionRouteKey ] . options . renderContainer
250+ || defaultRenderContainer ;
251+
222252 return (
223253 < TransitionContext . Provider value = { this . _transitionContext } >
224- { routeKeys . map ( ( key , index ) => {
254+ { renderContainerFunc ( transitionRouteKey , transitions , navigation ,
255+ transitioningFromState , transitionRouteKey ? navigation . state : null ,
256+ routeKeys . map ( ( key , index ) => {
225257 const ref =
226258 this . _transitionRefs [ key ] ||
227259 ( this . _transitionRefs [ key ] = React . createRef ( ) ) ;
@@ -246,34 +278,25 @@ export class Transitioner extends React.Component {
246278 return options . getBehindTransitionAnimatedStyle ( aboveTransition ) ;
247279 }
248280 ) ;
281+
249282 let transition = transitions [ key ] ;
250283 if ( behindScreenStyles . length === 0 ) {
251284 // bizarre react-native bug that refuses to clear Animated.View styles unless you do something like this..
252285 // to reproduce the problem, set a getBehindTransitionAnimatedStyle that puts opacity at 0.5
253286 behindScreenStyles = [ { opacity : 1 } ] ;
254287 }
288+
289+ const renderFunc = descriptor . options . renderScreen || defaultRenderScreen ;
290+
255291 return (
256- < Animated . View
257- style = { [ { ...StyleSheet . absoluteFillObject } , behindScreenStyles ] }
258- pointerEvents = { 'auto' }
259- key = { key }
260- >
261- < NavigationProvider value = { descriptor . navigation } >
262- < C
263- transition = { transition }
264- transitions = { transitions }
265- transitioningFromState = { transitioningFromState }
266- transitioningToState = {
267- transitionRouteKey ? this . props . navigation . state : null
268- }
269- transitionRouteKey = { transitionRouteKey }
270- navigation = { descriptor . navigation }
271- transitionRef = { ref }
272- />
273- </ NavigationProvider >
274- </ Animated . View >
292+ < NavigationProvider key = { key } value = { descriptor . navigation } >
293+ { renderFunc ( C , transition , transitions , transitioningFromState ,
294+ transitionRouteKey ? navigation . state : null ,
295+ transitionRouteKey , descriptor . navigation , ref ,
296+ behindScreenStyles , key ) }
297+ </ NavigationProvider >
275298 ) ;
276- } ) }
299+ } ) ) }
277300 </ TransitionContext . Provider >
278301 ) ;
279302 }
0 commit comments