@react-navigation/core 6.4.8 → 7.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/README.md +1 -1
  2. package/lib/commonjs/BaseNavigationContainer.js +71 -61
  3. package/lib/commonjs/BaseNavigationContainer.js.map +1 -1
  4. package/lib/commonjs/CurrentRenderContext.js +2 -3
  5. package/lib/commonjs/CurrentRenderContext.js.map +1 -1
  6. package/lib/commonjs/DeprecatedNavigationInChildContext.js +15 -0
  7. package/lib/commonjs/DeprecatedNavigationInChildContext.js.map +1 -0
  8. package/lib/commonjs/EnsureSingleNavigator.js +1 -1
  9. package/lib/commonjs/EnsureSingleNavigator.js.map +1 -1
  10. package/lib/commonjs/Group.js +1 -1
  11. package/lib/commonjs/Group.js.map +1 -1
  12. package/lib/commonjs/NavigationBuilderContext.js +2 -3
  13. package/lib/commonjs/NavigationBuilderContext.js.map +1 -1
  14. package/lib/commonjs/NavigationContainerRefContext.js +2 -3
  15. package/lib/commonjs/NavigationContainerRefContext.js.map +1 -1
  16. package/lib/commonjs/NavigationContext.js +2 -3
  17. package/lib/commonjs/NavigationContext.js.map +1 -1
  18. package/lib/commonjs/NavigationHelpersContext.js +2 -3
  19. package/lib/commonjs/NavigationHelpersContext.js.map +1 -1
  20. package/lib/commonjs/NavigationIndependentTree.js +32 -0
  21. package/lib/commonjs/NavigationIndependentTree.js.map +1 -0
  22. package/lib/commonjs/NavigationIndependentTreeContext.js +15 -0
  23. package/lib/commonjs/NavigationIndependentTreeContext.js.map +1 -0
  24. package/lib/commonjs/NavigationRouteContext.js +2 -3
  25. package/lib/commonjs/NavigationRouteContext.js.map +1 -1
  26. package/lib/commonjs/NavigationStateContext.js +3 -3
  27. package/lib/commonjs/NavigationStateContext.js.map +1 -1
  28. package/lib/commonjs/PreventRemoveContext.js +2 -3
  29. package/lib/commonjs/PreventRemoveContext.js.map +1 -1
  30. package/lib/commonjs/PreventRemoveProvider.js +8 -8
  31. package/lib/commonjs/PreventRemoveProvider.js.map +1 -1
  32. package/lib/commonjs/SceneView.js +8 -9
  33. package/lib/commonjs/SceneView.js.map +1 -1
  34. package/lib/commonjs/Screen.js +1 -1
  35. package/lib/commonjs/Screen.js.map +1 -1
  36. package/lib/commonjs/StaticContainer.js +4 -5
  37. package/lib/commonjs/StaticContainer.js.map +1 -1
  38. package/lib/commonjs/StaticNavigation.js +159 -0
  39. package/lib/commonjs/StaticNavigation.js.map +1 -0
  40. package/lib/commonjs/UnhandledActionContext.js +2 -3
  41. package/lib/commonjs/UnhandledActionContext.js.map +1 -1
  42. package/lib/commonjs/checkDuplicateRouteNames.js +1 -1
  43. package/lib/commonjs/checkDuplicateRouteNames.js.map +1 -1
  44. package/lib/commonjs/checkSerializable.js +1 -1
  45. package/lib/commonjs/checkSerializable.js.map +1 -1
  46. package/lib/commonjs/createNavigationContainerRef.js +1 -1
  47. package/lib/commonjs/createNavigationContainerRef.js.map +1 -1
  48. package/lib/commonjs/createNavigatorFactory.js +19 -11
  49. package/lib/commonjs/createNavigatorFactory.js.map +1 -1
  50. package/lib/commonjs/findFocusedRoute.js +1 -1
  51. package/lib/commonjs/findFocusedRoute.js.map +1 -1
  52. package/lib/commonjs/fromEntries.js +1 -1
  53. package/lib/commonjs/fromEntries.js.map +1 -1
  54. package/lib/commonjs/getActionFromState.js +1 -1
  55. package/lib/commonjs/getActionFromState.js.map +1 -1
  56. package/lib/commonjs/getFocusedRouteNameFromRoute.js +1 -1
  57. package/lib/commonjs/getFocusedRouteNameFromRoute.js.map +1 -1
  58. package/lib/commonjs/getPathFromState.js +6 -7
  59. package/lib/commonjs/getPathFromState.js.map +1 -1
  60. package/lib/commonjs/getStateFromPath.js +5 -5
  61. package/lib/commonjs/getStateFromPath.js.map +1 -1
  62. package/lib/commonjs/index.js +83 -53
  63. package/lib/commonjs/index.js.map +1 -1
  64. package/lib/commonjs/isArrayEqual.js +1 -1
  65. package/lib/commonjs/isArrayEqual.js.map +1 -1
  66. package/lib/commonjs/isRecordEqual.js +1 -1
  67. package/lib/commonjs/isRecordEqual.js.map +1 -1
  68. package/lib/commonjs/useChildListeners.js +1 -1
  69. package/lib/commonjs/useChildListeners.js.map +1 -1
  70. package/lib/commonjs/useComponent.js +1 -1
  71. package/lib/commonjs/useComponent.js.map +1 -1
  72. package/lib/commonjs/useCurrentRender.js +3 -4
  73. package/lib/commonjs/useCurrentRender.js.map +1 -1
  74. package/lib/commonjs/useDescriptors.js +31 -29
  75. package/lib/commonjs/useDescriptors.js.map +1 -1
  76. package/lib/commonjs/useEventEmitter.js +1 -1
  77. package/lib/commonjs/useEventEmitter.js.map +1 -1
  78. package/lib/commonjs/useFocusEffect.js +3 -4
  79. package/lib/commonjs/useFocusEffect.js.map +1 -1
  80. package/lib/commonjs/useFocusEvents.js +3 -4
  81. package/lib/commonjs/useFocusEvents.js.map +1 -1
  82. package/lib/commonjs/useFocusedListenersChildrenAdapter.js +3 -4
  83. package/lib/commonjs/useFocusedListenersChildrenAdapter.js.map +1 -1
  84. package/lib/commonjs/useIsFocused.js +3 -4
  85. package/lib/commonjs/useIsFocused.js.map +1 -1
  86. package/lib/commonjs/useKeyedChildListeners.js +1 -1
  87. package/lib/commonjs/useKeyedChildListeners.js.map +1 -1
  88. package/lib/commonjs/useNavigation.js +5 -6
  89. package/lib/commonjs/useNavigation.js.map +1 -1
  90. package/lib/commonjs/useNavigationBuilder.js +45 -46
  91. package/lib/commonjs/useNavigationBuilder.js.map +1 -1
  92. package/lib/commonjs/useNavigationCache.js +12 -11
  93. package/lib/commonjs/useNavigationCache.js.map +1 -1
  94. package/lib/commonjs/useNavigationContainerRef.js +3 -4
  95. package/lib/commonjs/useNavigationContainerRef.js.map +1 -1
  96. package/lib/commonjs/useNavigationHelpers.js +5 -6
  97. package/lib/commonjs/useNavigationHelpers.js.map +1 -1
  98. package/lib/commonjs/useNavigationIndependentTree.js +14 -0
  99. package/lib/commonjs/useNavigationIndependentTree.js.map +1 -0
  100. package/lib/commonjs/useNavigationState.js +3 -4
  101. package/lib/commonjs/useNavigationState.js.map +1 -1
  102. package/lib/commonjs/useOnAction.js +16 -13
  103. package/lib/commonjs/useOnAction.js.map +1 -1
  104. package/lib/commonjs/useOnGetState.js +7 -8
  105. package/lib/commonjs/useOnGetState.js.map +1 -1
  106. package/lib/commonjs/useOnPreventRemove.js +5 -6
  107. package/lib/commonjs/useOnPreventRemove.js.map +1 -1
  108. package/lib/commonjs/useOnRouteFocus.js +3 -4
  109. package/lib/commonjs/useOnRouteFocus.js.map +1 -1
  110. package/lib/commonjs/useOptionsGetters.js +5 -6
  111. package/lib/commonjs/useOptionsGetters.js.map +1 -1
  112. package/lib/commonjs/usePreventRemove.js +8 -8
  113. package/lib/commonjs/usePreventRemove.js.map +1 -1
  114. package/lib/commonjs/usePreventRemoveContext.js +3 -4
  115. package/lib/commonjs/usePreventRemoveContext.js.map +1 -1
  116. package/lib/commonjs/useRegisterNavigator.js +1 -1
  117. package/lib/commonjs/useRegisterNavigator.js.map +1 -1
  118. package/lib/commonjs/useRoute.js +3 -4
  119. package/lib/commonjs/useRoute.js.map +1 -1
  120. package/lib/commonjs/useRouteCache.js +1 -1
  121. package/lib/commonjs/useRouteCache.js.map +1 -1
  122. package/lib/commonjs/useScheduleUpdate.js +1 -1
  123. package/lib/commonjs/useScheduleUpdate.js.map +1 -1
  124. package/lib/commonjs/useSyncState.js +1 -1
  125. package/lib/commonjs/useSyncState.js.map +1 -1
  126. package/lib/commonjs/validatePathConfig.js +1 -1
  127. package/lib/commonjs/validatePathConfig.js.map +1 -1
  128. package/lib/module/BaseNavigationContainer.js +58 -48
  129. package/lib/module/BaseNavigationContainer.js.map +1 -1
  130. package/lib/module/CurrentRenderContext.js +1 -2
  131. package/lib/module/CurrentRenderContext.js.map +1 -1
  132. package/lib/module/DeprecatedNavigationInChildContext.js +7 -0
  133. package/lib/module/DeprecatedNavigationInChildContext.js.map +1 -0
  134. package/lib/module/EnsureSingleNavigator.js +1 -1
  135. package/lib/module/EnsureSingleNavigator.js.map +1 -1
  136. package/lib/module/Group.js +1 -1
  137. package/lib/module/Group.js.map +1 -1
  138. package/lib/module/NavigationBuilderContext.js +1 -2
  139. package/lib/module/NavigationBuilderContext.js.map +1 -1
  140. package/lib/module/NavigationContainerRefContext.js +1 -2
  141. package/lib/module/NavigationContainerRefContext.js.map +1 -1
  142. package/lib/module/NavigationContext.js +1 -2
  143. package/lib/module/NavigationContext.js.map +1 -1
  144. package/lib/module/NavigationHelpersContext.js +1 -2
  145. package/lib/module/NavigationHelpersContext.js.map +1 -1
  146. package/lib/module/NavigationIndependentTree.js +25 -0
  147. package/lib/module/NavigationIndependentTree.js.map +1 -0
  148. package/lib/module/NavigationIndependentTreeContext.js +7 -0
  149. package/lib/module/NavigationIndependentTreeContext.js.map +1 -0
  150. package/lib/module/NavigationRouteContext.js +1 -2
  151. package/lib/module/NavigationRouteContext.js.map +1 -1
  152. package/lib/module/NavigationStateContext.js +1 -1
  153. package/lib/module/NavigationStateContext.js.map +1 -1
  154. package/lib/module/PreventRemoveContext.js +1 -2
  155. package/lib/module/PreventRemoveContext.js.map +1 -1
  156. package/lib/module/PreventRemoveProvider.js +4 -4
  157. package/lib/module/PreventRemoveProvider.js.map +1 -1
  158. package/lib/module/SceneView.js +5 -5
  159. package/lib/module/SceneView.js.map +1 -1
  160. package/lib/module/Screen.js +1 -1
  161. package/lib/module/Screen.js.map +1 -1
  162. package/lib/module/StaticContainer.js +2 -3
  163. package/lib/module/StaticContainer.js.map +1 -1
  164. package/lib/module/StaticNavigation.js +156 -0
  165. package/lib/module/StaticNavigation.js.map +1 -0
  166. package/lib/module/UnhandledActionContext.js +1 -2
  167. package/lib/module/UnhandledActionContext.js.map +1 -1
  168. package/lib/module/checkDuplicateRouteNames.js +1 -1
  169. package/lib/module/checkDuplicateRouteNames.js.map +1 -1
  170. package/lib/module/checkSerializable.js +1 -1
  171. package/lib/module/checkSerializable.js.map +1 -1
  172. package/lib/module/createNavigationContainerRef.js +1 -1
  173. package/lib/module/createNavigationContainerRef.js.map +1 -1
  174. package/lib/module/createNavigatorFactory.js +19 -10
  175. package/lib/module/createNavigatorFactory.js.map +1 -1
  176. package/lib/module/findFocusedRoute.js +1 -1
  177. package/lib/module/findFocusedRoute.js.map +1 -1
  178. package/lib/module/fromEntries.js +1 -1
  179. package/lib/module/fromEntries.js.map +1 -1
  180. package/lib/module/getActionFromState.js +1 -1
  181. package/lib/module/getActionFromState.js.map +1 -1
  182. package/lib/module/getFocusedRouteNameFromRoute.js +1 -1
  183. package/lib/module/getFocusedRouteNameFromRoute.js.map +1 -1
  184. package/lib/module/getPathFromState.js +3 -3
  185. package/lib/module/getPathFromState.js.map +1 -1
  186. package/lib/module/getStateFromPath.js +3 -3
  187. package/lib/module/getStateFromPath.js.map +1 -1
  188. package/lib/module/index.js +28 -25
  189. package/lib/module/index.js.map +1 -1
  190. package/lib/module/isArrayEqual.js +1 -1
  191. package/lib/module/isArrayEqual.js.map +1 -1
  192. package/lib/module/isRecordEqual.js +1 -1
  193. package/lib/module/isRecordEqual.js.map +1 -1
  194. package/lib/module/useChildListeners.js +1 -1
  195. package/lib/module/useChildListeners.js.map +1 -1
  196. package/lib/module/useComponent.js +1 -1
  197. package/lib/module/useComponent.js.map +1 -1
  198. package/lib/module/useCurrentRender.js +2 -2
  199. package/lib/module/useCurrentRender.js.map +1 -1
  200. package/lib/module/useDescriptors.js +28 -25
  201. package/lib/module/useDescriptors.js.map +1 -1
  202. package/lib/module/useEventEmitter.js +1 -1
  203. package/lib/module/useEventEmitter.js.map +1 -1
  204. package/lib/module/useFocusEffect.js +2 -2
  205. package/lib/module/useFocusEffect.js.map +1 -1
  206. package/lib/module/useFocusEvents.js +2 -2
  207. package/lib/module/useFocusEvents.js.map +1 -1
  208. package/lib/module/useFocusedListenersChildrenAdapter.js +2 -2
  209. package/lib/module/useFocusedListenersChildrenAdapter.js.map +1 -1
  210. package/lib/module/useIsFocused.js +2 -2
  211. package/lib/module/useIsFocused.js.map +1 -1
  212. package/lib/module/useKeyedChildListeners.js +1 -1
  213. package/lib/module/useKeyedChildListeners.js.map +1 -1
  214. package/lib/module/useNavigation.js +3 -3
  215. package/lib/module/useNavigation.js.map +1 -1
  216. package/lib/module/useNavigationBuilder.js +24 -24
  217. package/lib/module/useNavigationBuilder.js.map +1 -1
  218. package/lib/module/useNavigationCache.js +11 -9
  219. package/lib/module/useNavigationCache.js.map +1 -1
  220. package/lib/module/useNavigationContainerRef.js +2 -2
  221. package/lib/module/useNavigationContainerRef.js.map +1 -1
  222. package/lib/module/useNavigationHelpers.js +3 -3
  223. package/lib/module/useNavigationHelpers.js.map +1 -1
  224. package/lib/module/useNavigationIndependentTree.js +6 -0
  225. package/lib/module/useNavigationIndependentTree.js.map +1 -0
  226. package/lib/module/useNavigationState.js +2 -2
  227. package/lib/module/useNavigationState.js.map +1 -1
  228. package/lib/module/useOnAction.js +14 -10
  229. package/lib/module/useOnAction.js.map +1 -1
  230. package/lib/module/useOnGetState.js +4 -4
  231. package/lib/module/useOnGetState.js.map +1 -1
  232. package/lib/module/useOnPreventRemove.js +3 -3
  233. package/lib/module/useOnPreventRemove.js.map +1 -1
  234. package/lib/module/useOnRouteFocus.js +2 -2
  235. package/lib/module/useOnRouteFocus.js.map +1 -1
  236. package/lib/module/useOptionsGetters.js +3 -3
  237. package/lib/module/useOptionsGetters.js.map +1 -1
  238. package/lib/module/usePreventRemove.js +4 -4
  239. package/lib/module/usePreventRemove.js.map +1 -1
  240. package/lib/module/usePreventRemoveContext.js +2 -2
  241. package/lib/module/usePreventRemoveContext.js.map +1 -1
  242. package/lib/module/useRegisterNavigator.js +1 -1
  243. package/lib/module/useRegisterNavigator.js.map +1 -1
  244. package/lib/module/useRoute.js +2 -2
  245. package/lib/module/useRoute.js.map +1 -1
  246. package/lib/module/useRouteCache.js +1 -1
  247. package/lib/module/useRouteCache.js.map +1 -1
  248. package/lib/module/useScheduleUpdate.js +1 -1
  249. package/lib/module/useScheduleUpdate.js.map +1 -1
  250. package/lib/module/useSyncState.js +1 -1
  251. package/lib/module/useSyncState.js.map +1 -1
  252. package/lib/module/validatePathConfig.js +1 -1
  253. package/lib/module/validatePathConfig.js.map +1 -1
  254. package/lib/typescript/src/BaseNavigationContainer.d.ts +3 -2
  255. package/lib/typescript/src/BaseNavigationContainer.d.ts.map +1 -1
  256. package/lib/typescript/src/CurrentRenderContext.d.ts +1 -2
  257. package/lib/typescript/src/CurrentRenderContext.d.ts.map +1 -1
  258. package/lib/typescript/src/DeprecatedNavigationInChildContext.d.ts +6 -0
  259. package/lib/typescript/src/DeprecatedNavigationInChildContext.d.ts.map +1 -0
  260. package/lib/typescript/src/EnsureSingleNavigator.d.ts +2 -2
  261. package/lib/typescript/src/EnsureSingleNavigator.d.ts.map +1 -1
  262. package/lib/typescript/src/Group.d.ts +1 -1
  263. package/lib/typescript/src/Group.d.ts.map +1 -1
  264. package/lib/typescript/src/NavigationBuilderContext.d.ts +10 -11
  265. package/lib/typescript/src/NavigationBuilderContext.d.ts.map +1 -1
  266. package/lib/typescript/src/NavigationContainerRefContext.d.ts +1 -2
  267. package/lib/typescript/src/NavigationContainerRefContext.d.ts.map +1 -1
  268. package/lib/typescript/src/NavigationContext.d.ts +1 -2
  269. package/lib/typescript/src/NavigationContext.d.ts.map +1 -1
  270. package/lib/typescript/src/NavigationHelpersContext.d.ts +1 -2
  271. package/lib/typescript/src/NavigationHelpersContext.d.ts.map +1 -1
  272. package/lib/typescript/src/NavigationIndependentTree.d.ts +8 -0
  273. package/lib/typescript/src/NavigationIndependentTree.d.ts.map +1 -0
  274. package/lib/typescript/src/NavigationIndependentTreeContext.d.ts +6 -0
  275. package/lib/typescript/src/NavigationIndependentTreeContext.d.ts.map +1 -0
  276. package/lib/typescript/src/NavigationRouteContext.d.ts +1 -2
  277. package/lib/typescript/src/NavigationRouteContext.d.ts.map +1 -1
  278. package/lib/typescript/src/NavigationStateContext.d.ts +1 -2
  279. package/lib/typescript/src/NavigationStateContext.d.ts.map +1 -1
  280. package/lib/typescript/src/PreventRemoveContext.d.ts +2 -3
  281. package/lib/typescript/src/PreventRemoveContext.d.ts.map +1 -1
  282. package/lib/typescript/src/PreventRemoveProvider.d.ts +2 -2
  283. package/lib/typescript/src/PreventRemoveProvider.d.ts.map +1 -1
  284. package/lib/typescript/src/SceneView.d.ts +2 -2
  285. package/lib/typescript/src/SceneView.d.ts.map +1 -1
  286. package/lib/typescript/src/Screen.d.ts +1 -1
  287. package/lib/typescript/src/Screen.d.ts.map +1 -1
  288. package/lib/typescript/src/StaticContainer.d.ts +1 -3
  289. package/lib/typescript/src/StaticContainer.d.ts.map +1 -1
  290. package/lib/typescript/src/StaticNavigation.d.ts +159 -0
  291. package/lib/typescript/src/StaticNavigation.d.ts.map +1 -0
  292. package/lib/typescript/src/UnhandledActionContext.d.ts +1 -2
  293. package/lib/typescript/src/UnhandledActionContext.d.ts.map +1 -1
  294. package/lib/typescript/src/checkDuplicateRouteNames.d.ts +1 -1
  295. package/lib/typescript/src/checkDuplicateRouteNames.d.ts.map +1 -1
  296. package/lib/typescript/src/checkSerializable.d.ts +1 -1
  297. package/lib/typescript/src/checkSerializable.d.ts.map +1 -1
  298. package/lib/typescript/src/createNavigationContainerRef.d.ts +1 -1
  299. package/lib/typescript/src/createNavigationContainerRef.d.ts.map +1 -1
  300. package/lib/typescript/src/createNavigatorFactory.d.ts +8 -2
  301. package/lib/typescript/src/createNavigatorFactory.d.ts.map +1 -1
  302. package/lib/typescript/src/findFocusedRoute.d.ts +1 -1
  303. package/lib/typescript/src/findFocusedRoute.d.ts.map +1 -1
  304. package/lib/typescript/src/fromEntries.d.ts +1 -1
  305. package/lib/typescript/src/fromEntries.d.ts.map +1 -1
  306. package/lib/typescript/src/getActionFromState.d.ts +3 -3
  307. package/lib/typescript/src/getActionFromState.d.ts.map +1 -1
  308. package/lib/typescript/src/getFocusedRouteNameFromRoute.d.ts +1 -1
  309. package/lib/typescript/src/getFocusedRouteNameFromRoute.d.ts.map +1 -1
  310. package/lib/typescript/src/getPathFromState.d.ts +3 -3
  311. package/lib/typescript/src/getPathFromState.d.ts.map +1 -1
  312. package/lib/typescript/src/getStateFromPath.d.ts +3 -3
  313. package/lib/typescript/src/getStateFromPath.d.ts.map +1 -1
  314. package/lib/typescript/src/index.d.ts +28 -25
  315. package/lib/typescript/src/index.d.ts.map +1 -1
  316. package/lib/typescript/src/isArrayEqual.d.ts +1 -1
  317. package/lib/typescript/src/isArrayEqual.d.ts.map +1 -1
  318. package/lib/typescript/src/isRecordEqual.d.ts +1 -1
  319. package/lib/typescript/src/isRecordEqual.d.ts.map +1 -1
  320. package/lib/typescript/src/types.d.ts +109 -48
  321. package/lib/typescript/src/types.d.ts.map +1 -1
  322. package/lib/typescript/src/useChildListeners.d.ts +1 -1
  323. package/lib/typescript/src/useChildListeners.d.ts.map +1 -1
  324. package/lib/typescript/src/useComponent.d.ts +2 -2
  325. package/lib/typescript/src/useComponent.d.ts.map +1 -1
  326. package/lib/typescript/src/useCurrentRender.d.ts +2 -2
  327. package/lib/typescript/src/useCurrentRender.d.ts.map +1 -1
  328. package/lib/typescript/src/useDescriptors.d.ts +12 -10
  329. package/lib/typescript/src/useDescriptors.d.ts.map +1 -1
  330. package/lib/typescript/src/useEventEmitter.d.ts +2 -2
  331. package/lib/typescript/src/useEventEmitter.d.ts.map +1 -1
  332. package/lib/typescript/src/useFocusEffect.d.ts +2 -2
  333. package/lib/typescript/src/useFocusEffect.d.ts.map +1 -1
  334. package/lib/typescript/src/useFocusEvents.d.ts +2 -2
  335. package/lib/typescript/src/useFocusEvents.d.ts.map +1 -1
  336. package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts +2 -2
  337. package/lib/typescript/src/useFocusedListenersChildrenAdapter.d.ts.map +1 -1
  338. package/lib/typescript/src/useIsFocused.d.ts +1 -1
  339. package/lib/typescript/src/useIsFocused.d.ts.map +1 -1
  340. package/lib/typescript/src/useKeyedChildListeners.d.ts +1 -1
  341. package/lib/typescript/src/useKeyedChildListeners.d.ts.map +1 -1
  342. package/lib/typescript/src/useNavigation.d.ts +1 -1
  343. package/lib/typescript/src/useNavigation.d.ts.map +1 -1
  344. package/lib/typescript/src/useNavigationBuilder.d.ts +20 -16
  345. package/lib/typescript/src/useNavigationBuilder.d.ts.map +1 -1
  346. package/lib/typescript/src/useNavigationCache.d.ts +4 -4
  347. package/lib/typescript/src/useNavigationCache.d.ts.map +1 -1
  348. package/lib/typescript/src/useNavigationContainerRef.d.ts +1 -1
  349. package/lib/typescript/src/useNavigationContainerRef.d.ts.map +1 -1
  350. package/lib/typescript/src/useNavigationHelpers.d.ts +28 -10
  351. package/lib/typescript/src/useNavigationHelpers.d.ts.map +1 -1
  352. package/lib/typescript/src/useNavigationIndependentTree.d.ts +2 -0
  353. package/lib/typescript/src/useNavigationIndependentTree.d.ts.map +1 -0
  354. package/lib/typescript/src/useNavigationState.d.ts +2 -2
  355. package/lib/typescript/src/useNavigationState.d.ts.map +1 -1
  356. package/lib/typescript/src/useOnAction.d.ts +2 -2
  357. package/lib/typescript/src/useOnAction.d.ts.map +1 -1
  358. package/lib/typescript/src/useOnGetState.d.ts +2 -2
  359. package/lib/typescript/src/useOnGetState.d.ts.map +1 -1
  360. package/lib/typescript/src/useOnPreventRemove.d.ts +2 -2
  361. package/lib/typescript/src/useOnPreventRemove.d.ts.map +1 -1
  362. package/lib/typescript/src/useOnRouteFocus.d.ts +2 -2
  363. package/lib/typescript/src/useOnRouteFocus.d.ts.map +1 -1
  364. package/lib/typescript/src/useOptionsGetters.d.ts +2 -2
  365. package/lib/typescript/src/useOptionsGetters.d.ts.map +1 -1
  366. package/lib/typescript/src/usePreventRemove.d.ts +1 -1
  367. package/lib/typescript/src/usePreventRemove.d.ts.map +1 -1
  368. package/lib/typescript/src/usePreventRemoveContext.d.ts +1 -1
  369. package/lib/typescript/src/usePreventRemoveContext.d.ts.map +1 -1
  370. package/lib/typescript/src/useRegisterNavigator.d.ts +1 -1
  371. package/lib/typescript/src/useRegisterNavigator.d.ts.map +1 -1
  372. package/lib/typescript/src/useRoute.d.ts +1 -1
  373. package/lib/typescript/src/useRoute.d.ts.map +1 -1
  374. package/lib/typescript/src/useRouteCache.d.ts +1 -1
  375. package/lib/typescript/src/useRouteCache.d.ts.map +1 -1
  376. package/lib/typescript/src/useScheduleUpdate.d.ts +1 -1
  377. package/lib/typescript/src/useScheduleUpdate.d.ts.map +1 -1
  378. package/lib/typescript/src/useSyncState.d.ts +1 -1
  379. package/lib/typescript/src/useSyncState.d.ts.map +1 -1
  380. package/lib/typescript/src/validatePathConfig.d.ts +1 -1
  381. package/lib/typescript/src/validatePathConfig.d.ts.map +1 -1
  382. package/package.json +11 -11
  383. package/src/BaseNavigationContainer.tsx +82 -80
  384. package/src/CurrentRenderContext.tsx +1 -3
  385. package/src/DeprecatedNavigationInChildContext.tsx +6 -0
  386. package/src/EnsureSingleNavigator.tsx +1 -1
  387. package/src/Group.tsx +1 -1
  388. package/src/NavigationBuilderContext.tsx +1 -3
  389. package/src/NavigationContainerRefContext.tsx +1 -3
  390. package/src/NavigationContext.tsx +1 -3
  391. package/src/NavigationHelpersContext.tsx +1 -3
  392. package/src/NavigationIndependentTree.tsx +25 -0
  393. package/src/NavigationIndependentTreeContext.tsx +6 -0
  394. package/src/NavigationRouteContext.tsx +3 -5
  395. package/src/NavigationStateContext.tsx +1 -1
  396. package/src/PreventRemoveContext.tsx +1 -3
  397. package/src/PreventRemoveProvider.tsx +4 -4
  398. package/src/SceneView.tsx +5 -5
  399. package/src/Screen.tsx +1 -1
  400. package/src/StaticContainer.tsx +19 -18
  401. package/src/StaticNavigation.tsx +401 -0
  402. package/src/UnhandledActionContext.tsx +1 -3
  403. package/src/checkDuplicateRouteNames.tsx +1 -1
  404. package/src/checkSerializable.tsx +1 -1
  405. package/src/createNavigationContainerRef.tsx +1 -1
  406. package/src/createNavigatorFactory.tsx +41 -12
  407. package/src/findFocusedRoute.tsx +1 -1
  408. package/src/fromEntries.tsx +1 -3
  409. package/src/getActionFromState.tsx +3 -9
  410. package/src/getFocusedRouteNameFromRoute.tsx +1 -1
  411. package/src/getPathFromState.tsx +4 -4
  412. package/src/getStateFromPath.tsx +3 -3
  413. package/src/index.tsx +34 -25
  414. package/src/isArrayEqual.tsx +1 -1
  415. package/src/isRecordEqual.tsx +1 -4
  416. package/src/types.tsx +111 -29
  417. package/src/useChildListeners.tsx +1 -1
  418. package/src/useComponent.tsx +1 -1
  419. package/src/useCurrentRender.tsx +2 -6
  420. package/src/useDescriptors.tsx +32 -26
  421. package/src/useEventEmitter.tsx +1 -1
  422. package/src/useFocusEffect.tsx +2 -2
  423. package/src/useFocusEvents.tsx +2 -2
  424. package/src/useFocusedListenersChildrenAdapter.tsx +3 -2
  425. package/src/useIsFocused.tsx +2 -2
  426. package/src/useKeyedChildListeners.tsx +1 -1
  427. package/src/useNavigation.tsx +3 -3
  428. package/src/useNavigationBuilder.tsx +33 -28
  429. package/src/useNavigationCache.tsx +10 -6
  430. package/src/useNavigationContainerRef.tsx +2 -2
  431. package/src/useNavigationHelpers.tsx +3 -3
  432. package/src/useNavigationIndependentTree.tsx +7 -0
  433. package/src/useNavigationState.tsx +2 -2
  434. package/src/useOnAction.tsx +17 -8
  435. package/src/useOnGetState.tsx +5 -7
  436. package/src/useOnPreventRemove.tsx +4 -3
  437. package/src/useOnRouteFocus.tsx +2 -2
  438. package/src/useOptionsGetters.tsx +3 -7
  439. package/src/usePreventRemove.tsx +4 -4
  440. package/src/usePreventRemoveContext.tsx +2 -2
  441. package/src/useRegisterNavigator.tsx +1 -1
  442. package/src/useRoute.tsx +2 -2
  443. package/src/useRouteCache.tsx +1 -1
  444. package/src/useScheduleUpdate.tsx +1 -1
  445. package/src/useSyncState.tsx +1 -1
  446. package/src/validatePathConfig.tsx +1 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-navigation/core",
3
3
  "description": "Core utilities for building navigators",
4
- "version": "6.4.8",
4
+ "version": "7.0.0-alpha.1",
5
5
  "keywords": [
6
6
  "react",
7
7
  "react-native",
@@ -35,23 +35,23 @@
35
35
  "clean": "del lib"
36
36
  },
37
37
  "dependencies": {
38
- "@react-navigation/routers": "^6.1.8",
38
+ "@react-navigation/routers": "^7.0.0-alpha.1",
39
39
  "escape-string-regexp": "^4.0.0",
40
40
  "nanoid": "^3.1.23",
41
41
  "query-string": "^7.1.3",
42
- "react-is": "^16.13.0",
42
+ "react-is": "^18.2.0",
43
43
  "use-latest-callback": "^0.1.5"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@testing-library/react-native": "^11.5.0",
47
- "@types/react": "~18.0.0",
48
- "@types/react-is": "^17.0.0",
49
- "del-cli": "^3.0.1",
50
- "immer": "^9.0.2",
51
- "react": "18.0.0",
47
+ "@types/react": "~18.0.26",
48
+ "@types/react-is": "^17.0.3",
49
+ "del-cli": "^5.0.0",
50
+ "immer": "^9.0.16",
51
+ "react": "18.1.0",
52
52
  "react-native-builder-bob": "^0.20.4",
53
- "react-test-renderer": "18.0.0",
54
- "typescript": "^4.7.4"
53
+ "react-test-renderer": "18.1.0",
54
+ "typescript": "^4.9.4"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "react": "*"
@@ -70,5 +70,5 @@
70
70
  ]
71
71
  ]
72
72
  },
73
- "gitHead": "ba6380c93f945e4c586f5e17e618208ab603bf30"
73
+ "gitHead": "230c09deeeb886929a15cb4cdcb496372a9496e1"
74
74
  }
@@ -8,29 +8,31 @@ import {
8
8
  Route,
9
9
  } from '@react-navigation/routers';
10
10
  import * as React from 'react';
11
+ import useLatestCallback from 'use-latest-callback';
11
12
 
12
- import checkDuplicateRouteNames from './checkDuplicateRouteNames';
13
- import checkSerializable from './checkSerializable';
13
+ import { checkDuplicateRouteNames } from './checkDuplicateRouteNames';
14
+ import { checkSerializable } from './checkSerializable';
14
15
  import { NOT_INITIALIZED_ERROR } from './createNavigationContainerRef';
15
- import EnsureSingleNavigator from './EnsureSingleNavigator';
16
- import findFocusedRoute from './findFocusedRoute';
17
- import NavigationBuilderContext from './NavigationBuilderContext';
18
- import NavigationContainerRefContext from './NavigationContainerRefContext';
19
- import NavigationContext from './NavigationContext';
20
- import NavigationRouteContext from './NavigationRouteContext';
21
- import NavigationStateContext from './NavigationStateContext';
16
+ import { DeprecatedNavigationInChildContext } from './DeprecatedNavigationInChildContext';
17
+ import { EnsureSingleNavigator } from './EnsureSingleNavigator';
18
+ import { findFocusedRoute } from './findFocusedRoute';
19
+ import { NavigationBuilderContext } from './NavigationBuilderContext';
20
+ import { NavigationContainerRefContext } from './NavigationContainerRefContext';
21
+ import { NavigationIndependentTreeContext } from './NavigationIndependentTreeContext';
22
+ import { NavigationStateContext } from './NavigationStateContext';
22
23
  import type {
23
24
  NavigationContainerEventMap,
24
25
  NavigationContainerProps,
25
26
  NavigationContainerRef,
26
27
  } from './types';
27
- import UnhandledActionContext from './UnhandledActionContext';
28
- import useChildListeners from './useChildListeners';
29
- import useEventEmitter from './useEventEmitter';
30
- import useKeyedChildListeners from './useKeyedChildListeners';
31
- import useOptionsGetters from './useOptionsGetters';
28
+ import { UnhandledActionContext } from './UnhandledActionContext';
29
+ import { useChildListeners } from './useChildListeners';
30
+ import { useEventEmitter } from './useEventEmitter';
31
+ import { useKeyedChildListeners } from './useKeyedChildListeners';
32
+ import { useNavigationIndependentTree } from './useNavigationIndependentTree';
33
+ import { useOptionsGetters } from './useOptionsGetters';
32
34
  import { ScheduleUpdateContext } from './useScheduleUpdate';
33
- import useSyncState from './useSyncState';
35
+ import { useSyncState } from './useSyncState';
34
36
 
35
37
  type State = NavigationState | PartialState<NavigationState> | undefined;
36
38
 
@@ -72,26 +74,30 @@ const getPartialState = (
72
74
  * This should be rendered at the root wrapping the whole app.
73
75
  *
74
76
  * @param props.initialState Initial state object for the navigation tree.
77
+ * @param props.onReady Callback which is called after the navigation tree mounts.
75
78
  * @param props.onStateChange Callback which is called with the latest navigation state when it changes.
79
+ * @param props.onUnhandledAction Callback which is called when an action is not handled.
76
80
  * @param props.children Child elements to render the content.
77
81
  * @param props.ref Ref object which refers to the navigation object containing helper methods.
78
82
  */
79
- const BaseNavigationContainer = React.forwardRef(
83
+ export const BaseNavigationContainer = React.forwardRef(
80
84
  function BaseNavigationContainer(
81
85
  {
82
86
  initialState,
83
87
  onStateChange,
88
+ onReady,
84
89
  onUnhandledAction,
85
- independent,
90
+ navigationInChildEnabled = false,
86
91
  children,
87
92
  }: NavigationContainerProps,
88
93
  ref?: React.Ref<NavigationContainerRef<ParamListBase>>
89
94
  ) {
90
95
  const parent = React.useContext(NavigationStateContext);
96
+ const independent = useNavigationIndependentTree();
91
97
 
92
98
  if (!parent.isDefault && !independent) {
93
99
  throw new Error(
94
- "Looks like you have nested a 'NavigationContainer' inside another. Normally you need only one container at the root of the app, so this was probably an error. If this was intentional, pass 'independent={true}' explicitly. Note that this will make the child navigators disconnected from the parent and you won't be able to navigate between them."
100
+ "Looks like you have nested a 'NavigationContainer' inside another. Normally you need only one container at the root of the app, so this was probably an error. If this was intentional, wrap the container in 'NavigationIndependentTree' explicitly. Note that this will make the child navigators disconnected from the parent and you won't be able to navigate between them."
95
101
  );
96
102
  }
97
103
 
@@ -114,7 +120,7 @@ const BaseNavigationContainer = React.forwardRef(
114
120
 
115
121
  const { keyedListeners, addKeyedListener } = useKeyedChildListeners();
116
122
 
117
- const dispatch = React.useCallback(
123
+ const dispatch = useLatestCallback(
118
124
  (
119
125
  action:
120
126
  | NavigationAction
@@ -125,11 +131,10 @@ const BaseNavigationContainer = React.forwardRef(
125
131
  } else {
126
132
  listeners.focus[0]((navigation) => navigation.dispatch(action));
127
133
  }
128
- },
129
- [listeners.focus]
134
+ }
130
135
  );
131
136
 
132
- const canGoBack = React.useCallback(() => {
137
+ const canGoBack = useLatestCallback(() => {
133
138
  if (listeners.focus[0] == null) {
134
139
  return false;
135
140
  }
@@ -143,9 +148,9 @@ const BaseNavigationContainer = React.forwardRef(
143
148
  } else {
144
149
  return false;
145
150
  }
146
- }, [listeners.focus]);
151
+ });
147
152
 
148
- const resetRoot = React.useCallback(
153
+ const resetRoot = useLatestCallback(
149
154
  (state?: PartialState<NavigationState> | NavigationState) => {
150
155
  const target = state?.key ?? keyedListeners.getState.root?.().key;
151
156
 
@@ -159,15 +164,14 @@ const BaseNavigationContainer = React.forwardRef(
159
164
  })
160
165
  );
161
166
  }
162
- },
163
- [keyedListeners.getState, listeners.focus]
167
+ }
164
168
  );
165
169
 
166
- const getRootState = React.useCallback(() => {
170
+ const getRootState = useLatestCallback(() => {
167
171
  return keyedListeners.getState.root?.();
168
- }, [keyedListeners.getState]);
172
+ });
169
173
 
170
- const getCurrentRoute = React.useCallback(() => {
174
+ const getCurrentRoute = useLatestCallback(() => {
171
175
  const state = getRootState();
172
176
 
173
177
  if (state == null) {
@@ -177,7 +181,9 @@ const BaseNavigationContainer = React.forwardRef(
177
181
  const route = findFocusedRoute(state);
178
182
 
179
183
  return route as Route<string> | undefined;
180
- }, [getRootState]);
184
+ });
185
+
186
+ const isReady = useLatestCallback(() => listeners.focus[0] != null);
181
187
 
182
188
  const emitter = useEventEmitter<NavigationContainerEventMap>();
183
189
 
@@ -201,7 +207,7 @@ const BaseNavigationContainer = React.forwardRef(
201
207
  getRootState,
202
208
  getCurrentRoute,
203
209
  getCurrentOptions,
204
- isReady: () => listeners.focus[0] != null,
210
+ isReady,
205
211
  }),
206
212
  [
207
213
  canGoBack,
@@ -210,40 +216,36 @@ const BaseNavigationContainer = React.forwardRef(
210
216
  getCurrentOptions,
211
217
  getCurrentRoute,
212
218
  getRootState,
213
- listeners.focus,
219
+ isReady,
214
220
  resetRoot,
215
221
  ]
216
222
  );
217
223
 
218
224
  React.useImperativeHandle(ref, () => navigation, [navigation]);
219
225
 
220
- const onDispatchAction = React.useCallback(
226
+ const onDispatchAction = useLatestCallback(
221
227
  (action: NavigationAction, noop: boolean) => {
222
228
  emitter.emit({
223
229
  type: '__unsafe_action__',
224
230
  data: { action, noop, stack: stackRef.current },
225
231
  });
226
- },
227
- [emitter]
232
+ }
228
233
  );
229
234
 
230
235
  const lastEmittedOptionsRef = React.useRef<object | undefined>();
231
236
 
232
- const onOptionsChange = React.useCallback(
233
- (options: object) => {
234
- if (lastEmittedOptionsRef.current === options) {
235
- return;
236
- }
237
+ const onOptionsChange = useLatestCallback((options: object) => {
238
+ if (lastEmittedOptionsRef.current === options) {
239
+ return;
240
+ }
237
241
 
238
- lastEmittedOptionsRef.current = options;
242
+ lastEmittedOptionsRef.current = options;
239
243
 
240
- emitter.emit({
241
- type: 'options',
242
- data: { options },
243
- });
244
- },
245
- [emitter]
246
- );
244
+ emitter.emit({
245
+ type: 'options',
246
+ data: { options },
247
+ });
248
+ });
247
249
 
248
250
  const stackRef = React.useRef<string | undefined>();
249
251
 
@@ -288,15 +290,25 @@ const BaseNavigationContainer = React.forwardRef(
288
290
  ]
289
291
  );
290
292
 
293
+ const onReadyRef = React.useRef(onReady);
291
294
  const onStateChangeRef = React.useRef(onStateChange);
292
295
  const stateRef = React.useRef(state);
293
296
 
294
297
  React.useEffect(() => {
295
298
  isInitialRef.current = false;
296
299
  onStateChangeRef.current = onStateChange;
300
+ onReadyRef.current = onReady;
297
301
  stateRef.current = state;
298
302
  });
299
303
 
304
+ const isNavigationReady = isReady();
305
+
306
+ React.useEffect(() => {
307
+ if (isNavigationReady) {
308
+ onReadyRef.current?.();
309
+ }
310
+ }, [isNavigationReady]);
311
+
300
312
  React.useEffect(() => {
301
313
  const hydratedState = getRootState();
302
314
 
@@ -376,7 +388,7 @@ const BaseNavigationContainer = React.forwardRef(
376
388
  isFirstMountRef.current = false;
377
389
  }, [getRootState, emitter, state]);
378
390
 
379
- const defaultOnUnhandledAction = React.useCallback(
391
+ const defaultOnUnhandledAction = useLatestCallback(
380
392
  (action: NavigationAction) => {
381
393
  if (process.env.NODE_ENV === 'production') {
382
394
  return;
@@ -415,39 +427,29 @@ const BaseNavigationContainer = React.forwardRef(
415
427
  message += `\n\nThis is a development-only warning and won't be shown in production.`;
416
428
 
417
429
  console.error(message);
418
- },
419
- []
430
+ }
420
431
  );
421
432
 
422
- let element = (
423
- <NavigationContainerRefContext.Provider value={navigation}>
424
- <ScheduleUpdateContext.Provider value={scheduleContext}>
425
- <NavigationBuilderContext.Provider value={builderContext}>
426
- <NavigationStateContext.Provider value={context}>
427
- <UnhandledActionContext.Provider
428
- value={onUnhandledAction ?? defaultOnUnhandledAction}
429
- >
430
- <EnsureSingleNavigator>{children}</EnsureSingleNavigator>
431
- </UnhandledActionContext.Provider>
432
- </NavigationStateContext.Provider>
433
- </NavigationBuilderContext.Provider>
434
- </ScheduleUpdateContext.Provider>
435
- </NavigationContainerRefContext.Provider>
433
+ return (
434
+ <NavigationIndependentTreeContext.Provider value={false}>
435
+ <NavigationContainerRefContext.Provider value={navigation}>
436
+ <ScheduleUpdateContext.Provider value={scheduleContext}>
437
+ <NavigationBuilderContext.Provider value={builderContext}>
438
+ <NavigationStateContext.Provider value={context}>
439
+ <UnhandledActionContext.Provider
440
+ value={onUnhandledAction ?? defaultOnUnhandledAction}
441
+ >
442
+ <DeprecatedNavigationInChildContext.Provider
443
+ value={navigationInChildEnabled}
444
+ >
445
+ <EnsureSingleNavigator>{children}</EnsureSingleNavigator>
446
+ </DeprecatedNavigationInChildContext.Provider>
447
+ </UnhandledActionContext.Provider>
448
+ </NavigationStateContext.Provider>
449
+ </NavigationBuilderContext.Provider>
450
+ </ScheduleUpdateContext.Provider>
451
+ </NavigationContainerRefContext.Provider>
452
+ </NavigationIndependentTreeContext.Provider>
436
453
  );
437
-
438
- if (independent) {
439
- // We need to clear any existing contexts for nested independent container to work correctly
440
- element = (
441
- <NavigationRouteContext.Provider value={undefined}>
442
- <NavigationContext.Provider value={undefined}>
443
- {element}
444
- </NavigationContext.Provider>
445
- </NavigationRouteContext.Provider>
446
- );
447
- }
448
-
449
- return element;
450
454
  }
451
455
  );
452
-
453
- export default BaseNavigationContainer;
@@ -4,8 +4,6 @@ import * as React from 'react';
4
4
  * Context which holds the values for the current navigation tree.
5
5
  * Intended for use in SSR. This is not safe to use on the client.
6
6
  */
7
- const CurrentRenderContext = React.createContext<
7
+ export const CurrentRenderContext = React.createContext<
8
8
  { options?: object } | undefined
9
9
  >(undefined);
10
-
11
- export default CurrentRenderContext;
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * Context which enables deprecated bubbling to child navigators.
5
+ */
6
+ export const DeprecatedNavigationInChildContext = React.createContext(false);
@@ -17,7 +17,7 @@ export const SingleNavigatorContext = React.createContext<
17
17
  /**
18
18
  * Component which ensures that there's only one navigator nested under it.
19
19
  */
20
- export default function EnsureSingleNavigator({ children }: Props) {
20
+ export function EnsureSingleNavigator({ children }: Props) {
21
21
  const navigatorKeyRef = React.useRef<string | undefined>();
22
22
 
23
23
  const value = React.useMemo(
package/src/Group.tsx CHANGED
@@ -5,7 +5,7 @@ import type { RouteGroupConfig } from './types';
5
5
  /**
6
6
  * Empty component used for grouping screen configs.
7
7
  */
8
- export default function Group<
8
+ export function Group<
9
9
  ParamList extends ParamListBase,
10
10
  ScreenOptions extends {}
11
11
  >(_: RouteGroupConfig<ParamList, ScreenOptions>) {
@@ -51,7 +51,7 @@ export type ChildBeforeRemoveListener = (action: NavigationAction) => boolean;
51
51
  /**
52
52
  * Context which holds the required helpers needed to build nested navigators.
53
53
  */
54
- const NavigationBuilderContext = React.createContext<{
54
+ export const NavigationBuilderContext = React.createContext<{
55
55
  onAction?: (
56
56
  action: NavigationAction,
57
57
  visitedNavigators?: Set<string>
@@ -66,5 +66,3 @@ const NavigationBuilderContext = React.createContext<{
66
66
  onDispatchAction: () => undefined,
67
67
  onOptionsChange: () => undefined,
68
68
  });
69
-
70
- export default NavigationBuilderContext;
@@ -6,8 +6,6 @@ import type { NavigationContainerRef } from './types';
6
6
  /**
7
7
  * Context which holds the route prop for a screen.
8
8
  */
9
- const NavigationContainerRefContext = React.createContext<
9
+ export const NavigationContainerRefContext = React.createContext<
10
10
  NavigationContainerRef<ParamListBase> | undefined
11
11
  >(undefined);
12
-
13
- export default NavigationContainerRefContext;
@@ -6,8 +6,6 @@ import type { NavigationProp } from './types';
6
6
  /**
7
7
  * Context which holds the navigation prop for a screen.
8
8
  */
9
- const NavigationContext = React.createContext<
9
+ export const NavigationContext = React.createContext<
10
10
  NavigationProp<ParamListBase> | undefined
11
11
  >(undefined);
12
-
13
- export default NavigationContext;
@@ -7,8 +7,6 @@ import type { NavigationHelpers } from './types';
7
7
  * Context which holds the navigation helpers of the parent navigator.
8
8
  * Navigators should use this context in their view component.
9
9
  */
10
- const NavigationHelpersContext = React.createContext<
10
+ export const NavigationHelpersContext = React.createContext<
11
11
  NavigationHelpers<ParamListBase> | undefined
12
12
  >(undefined);
13
-
14
- export default NavigationHelpersContext;
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+
3
+ import { NavigationContext } from './NavigationContext';
4
+ import { NavigationIndependentTreeContext } from './NavigationIndependentTreeContext';
5
+ import { NavigationRouteContext } from './NavigationRouteContext';
6
+
7
+ /**
8
+ * Component to make the child navigation container independent of parent containers.
9
+ */
10
+ export function NavigationIndependentTree({
11
+ children,
12
+ }: {
13
+ children: React.ReactNode;
14
+ }) {
15
+ return (
16
+ // We need to clear any existing contexts for nested independent container to work correctly
17
+ <NavigationRouteContext.Provider value={undefined}>
18
+ <NavigationContext.Provider value={undefined}>
19
+ <NavigationIndependentTreeContext.Provider value>
20
+ {children}
21
+ </NavigationIndependentTreeContext.Provider>
22
+ </NavigationContext.Provider>
23
+ </NavigationRouteContext.Provider>
24
+ );
25
+ }
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+
3
+ /**
4
+ * Context which marks the navigation tree as independent.
5
+ */
6
+ export const NavigationIndependentTreeContext = React.createContext(false);
@@ -4,8 +4,6 @@ import * as React from 'react';
4
4
  /**
5
5
  * Context which holds the route prop for a screen.
6
6
  */
7
- const NavigationRouteContext = React.createContext<Route<string> | undefined>(
8
- undefined
9
- );
10
-
11
- export default NavigationRouteContext;
7
+ export const NavigationRouteContext = React.createContext<
8
+ Route<string> | undefined
9
+ >(undefined);
@@ -4,7 +4,7 @@ import * as React from 'react';
4
4
  const MISSING_CONTEXT_ERROR =
5
5
  "Couldn't find a navigation context. Have you wrapped your app with 'NavigationContainer'? See https://reactnavigation.org/docs/getting-started for setup instructions.";
6
6
 
7
- export default React.createContext<{
7
+ export const NavigationStateContext = React.createContext<{
8
8
  isDefault?: true;
9
9
  state?: NavigationState | PartialState<NavigationState>;
10
10
  getKey: () => string | undefined;
@@ -6,7 +6,7 @@ import * as React from 'react';
6
6
  */
7
7
  export type PreventedRoutes = Record<string, { preventRemove: boolean }>;
8
8
 
9
- const PreventRemoveContext = React.createContext<
9
+ export const PreventRemoveContext = React.createContext<
10
10
  | {
11
11
  preventedRoutes: PreventedRoutes;
12
12
  setPreventRemove: (
@@ -17,5 +17,3 @@ const PreventRemoveContext = React.createContext<
17
17
  }
18
18
  | undefined
19
19
  >(undefined);
20
-
21
- export default PreventRemoveContext;
@@ -2,9 +2,9 @@ import { nanoid } from 'nanoid/non-secure';
2
2
  import * as React from 'react';
3
3
  import useLatestCallback from 'use-latest-callback';
4
4
 
5
- import NavigationHelpersContext from './NavigationHelpersContext';
6
- import NavigationRouteContext from './NavigationRouteContext';
7
- import PreventRemoveContext, { PreventedRoutes } from './PreventRemoveContext';
5
+ import { NavigationHelpersContext } from './NavigationHelpersContext';
6
+ import { NavigationRouteContext } from './NavigationRouteContext';
7
+ import { PreventedRoutes, PreventRemoveContext } from './PreventRemoveContext';
8
8
 
9
9
  type Props = {
10
10
  children: React.ReactNode;
@@ -42,7 +42,7 @@ const transformPreventedRoutes = (
42
42
  /**
43
43
  * Component used for managing which routes have to be prevented from removal in native-stack.
44
44
  */
45
- export default function PreventRemoveProvider({ children }: Props) {
45
+ export function PreventRemoveProvider({ children }: Props) {
46
46
  const [parentId] = React.useState(() => nanoid());
47
47
  const [preventedRoutesMap, setPreventedRoutesMap] =
48
48
  React.useState<PreventedRoutesMap>(new Map());
package/src/SceneView.tsx CHANGED
@@ -6,11 +6,11 @@ import type {
6
6
  } from '@react-navigation/routers';
7
7
  import * as React from 'react';
8
8
 
9
- import EnsureSingleNavigator from './EnsureSingleNavigator';
10
- import NavigationStateContext from './NavigationStateContext';
11
- import StaticContainer from './StaticContainer';
9
+ import { EnsureSingleNavigator } from './EnsureSingleNavigator';
10
+ import { NavigationStateContext } from './NavigationStateContext';
11
+ import { StaticContainer } from './StaticContainer';
12
12
  import type { NavigationProp, RouteConfigComponent } from './types';
13
- import useOptionsGetters from './useOptionsGetters';
13
+ import { useOptionsGetters } from './useOptionsGetters';
14
14
 
15
15
  type Props<State extends NavigationState, ScreenOptions extends {}> = {
16
16
  screen: RouteConfigComponent<ParamListBase, string> & { name: string };
@@ -33,7 +33,7 @@ type Props<State extends NavigationState, ScreenOptions extends {}> = {
33
33
  * Component which takes care of rendering the screen for a route.
34
34
  * It provides all required contexts and applies optimizations when applicable.
35
35
  */
36
- export default function SceneView<
36
+ export function SceneView<
37
37
  State extends NavigationState,
38
38
  ScreenOptions extends {}
39
39
  >({
package/src/Screen.tsx CHANGED
@@ -5,7 +5,7 @@ import type { EventMapBase, RouteConfig } from './types';
5
5
  /**
6
6
  * Empty component used for specifying route configuration.
7
7
  */
8
- export default function Screen<
8
+ export function Screen<
9
9
  ParamList extends ParamListBase,
10
10
  RouteName extends keyof ParamList,
11
11
  State extends NavigationState,
@@ -3,27 +3,28 @@ import * as React from 'react';
3
3
  /**
4
4
  * Component which prevents updates for children if no props changed
5
5
  */
6
- function StaticContainer(props: any) {
7
- return props.children;
8
- }
6
+ export const StaticContainer = React.memo(
7
+ function StaticContainer(props: any) {
8
+ return props.children;
9
+ },
10
+ (prevProps: any, nextProps: any) => {
11
+ const prevPropKeys = Object.keys(prevProps);
12
+ const nextPropKeys = Object.keys(nextProps);
9
13
 
10
- export default React.memo(StaticContainer, (prevProps: any, nextProps: any) => {
11
- const prevPropKeys = Object.keys(prevProps);
12
- const nextPropKeys = Object.keys(nextProps);
14
+ if (prevPropKeys.length !== nextPropKeys.length) {
15
+ return false;
16
+ }
13
17
 
14
- if (prevPropKeys.length !== nextPropKeys.length) {
15
- return false;
16
- }
18
+ for (const key of prevPropKeys) {
19
+ if (key === 'children') {
20
+ continue;
21
+ }
17
22
 
18
- for (const key of prevPropKeys) {
19
- if (key === 'children') {
20
- continue;
23
+ if (prevProps[key] !== nextProps[key]) {
24
+ return false;
25
+ }
21
26
  }
22
27
 
23
- if (prevProps[key] !== nextProps[key]) {
24
- return false;
25
- }
28
+ return true;
26
29
  }
27
-
28
- return true;
29
- });
30
+ );