@@ -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+ key = { key }
48+ >
49+ < ScreenComponent
50+ transition = { transition }
51+ transitions = { transitions }
52+ transitioningFromState = { transitioningFromState }
53+ transitioningToState = { transitioningToState }
54+ transitionRouteKey = { transitionRouteKey }
55+ navigation = { navigation }
56+ transitionRef = { ref }
57+ />
58+ </ Animated . View >
59+ ) ;
60+
61+ const defaultRenderContainer = ( 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 { navigationConfig, navigation } = this . props ;
211237 const mainRouteKeys = navState . routes . map ( r => r . key ) ;
212238 let routeKeys = mainRouteKeys ;
213239
@@ -219,9 +245,16 @@ export class Transitioner extends React.Component {
219245 }
220246 }
221247
248+ // Use render container function from last route descriptor
249+ const renderContainerFunc = navigationConfig && navigationConfig . navigationOptions
250+ && navigationConfig . navigationOptions . renderContainer
251+ || defaultRenderContainer ;
252+
222253 return (
223254 < TransitionContext . Provider value = { this . _transitionContext } >
224- { routeKeys . map ( ( key , index ) => {
255+ { renderContainerFunc ( transitionRouteKey , transitions , navigation ,
256+ transitioningFromState , transitionRouteKey ? navigation . state : null ,
257+ routeKeys . map ( ( key , index ) => {
225258 const ref =
226259 this . _transitionRefs [ key ] ||
227260 ( this . _transitionRefs [ key ] = React . createRef ( ) ) ;
@@ -246,34 +279,25 @@ export class Transitioner extends React.Component {
246279 return options . getBehindTransitionAnimatedStyle ( aboveTransition ) ;
247280 }
248281 ) ;
282+
249283 let transition = transitions [ key ] ;
250284 if ( behindScreenStyles . length === 0 ) {
251285 // bizarre react-native bug that refuses to clear Animated.View styles unless you do something like this..
252286 // to reproduce the problem, set a getBehindTransitionAnimatedStyle that puts opacity at 0.5
253287 behindScreenStyles = [ { opacity : 1 } ] ;
254288 }
289+
290+ const renderFunc = descriptor . options . renderScreen || defaultRenderScreen ;
291+
255292 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 >
293+ < NavigationProvider value = { descriptor . navigation } >
294+ { renderFunc ( C , transition , transitions , transitioningFromState ,
295+ transitionRouteKey ? navigation . state : null ,
296+ transitionRouteKey , descriptor . navigation , ref ,
297+ behindScreenStyles ) }
298+ </ NavigationProvider >
275299 ) ;
276- } ) }
300+ } ) ) }
277301 </ TransitionContext . Provider >
278302 ) ;
279303 }
0 commit comments