@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/src/index.tsx CHANGED
@@ -1,27 +1,36 @@
1
- export { default as BaseNavigationContainer } from './BaseNavigationContainer';
2
- export { default as createNavigationContainerRef } from './createNavigationContainerRef';
3
- export { default as createNavigatorFactory } from './createNavigatorFactory';
4
- export { default as CurrentRenderContext } from './CurrentRenderContext';
5
- export { default as findFocusedRoute } from './findFocusedRoute';
6
- export { default as getActionFromState } from './getActionFromState';
7
- export { default as getFocusedRouteNameFromRoute } from './getFocusedRouteNameFromRoute';
8
- export { default as getPathFromState } from './getPathFromState';
9
- export { default as getStateFromPath } from './getStateFromPath';
10
- export { default as NavigationContainerRefContext } from './NavigationContainerRefContext';
11
- export { default as NavigationContext } from './NavigationContext';
12
- export { default as NavigationHelpersContext } from './NavigationHelpersContext';
13
- export { default as NavigationRouteContext } from './NavigationRouteContext';
14
- export { default as PreventRemoveContext } from './PreventRemoveContext';
15
- export { default as PreventRemoveProvider } from './PreventRemoveProvider';
1
+ export { BaseNavigationContainer } from './BaseNavigationContainer';
2
+ export { createNavigationContainerRef } from './createNavigationContainerRef';
3
+ export { createNavigatorFactory } from './createNavigatorFactory';
4
+ export { CurrentRenderContext } from './CurrentRenderContext';
5
+ export { findFocusedRoute } from './findFocusedRoute';
6
+ export { getActionFromState } from './getActionFromState';
7
+ export { getFocusedRouteNameFromRoute } from './getFocusedRouteNameFromRoute';
8
+ export { getPathFromState } from './getPathFromState';
9
+ export { getStateFromPath } from './getStateFromPath';
10
+ export { NavigationContainerRefContext } from './NavigationContainerRefContext';
11
+ export { NavigationContext } from './NavigationContext';
12
+ export { NavigationHelpersContext } from './NavigationHelpersContext';
13
+ export { NavigationIndependentTree } from './NavigationIndependentTree';
14
+ export { NavigationRouteContext } from './NavigationRouteContext';
15
+ export { PreventRemoveContext } from './PreventRemoveContext';
16
+ export { PreventRemoveProvider } from './PreventRemoveProvider';
17
+ export {
18
+ type StaticNavigation,
19
+ type StaticParamList,
20
+ type StaticScreenProps,
21
+ createComponentForStaticNavigation,
22
+ createPathConfigForStaticNavigation,
23
+ } from './StaticNavigation';
16
24
  export * from './types';
17
- export { default as useFocusEffect } from './useFocusEffect';
18
- export { default as useIsFocused } from './useIsFocused';
19
- export { default as useNavigation } from './useNavigation';
20
- export { default as useNavigationBuilder } from './useNavigationBuilder';
21
- export { default as useNavigationContainerRef } from './useNavigationContainerRef';
22
- export { default as useNavigationState } from './useNavigationState';
23
- export { default as UNSTABLE_usePreventRemove } from './usePreventRemove';
24
- export { default as usePreventRemoveContext } from './usePreventRemoveContext';
25
- export { default as useRoute } from './useRoute';
26
- export { default as validatePathConfig } from './validatePathConfig';
25
+ export { useFocusEffect } from './useFocusEffect';
26
+ export { useIsFocused } from './useIsFocused';
27
+ export { useNavigation } from './useNavigation';
28
+ export { useNavigationBuilder } from './useNavigationBuilder';
29
+ export { useNavigationContainerRef } from './useNavigationContainerRef';
30
+ export { useNavigationIndependentTree } from './useNavigationIndependentTree';
31
+ export { useNavigationState } from './useNavigationState';
32
+ export { UNSTABLE_usePreventRemove } from './usePreventRemove';
33
+ export { usePreventRemoveContext } from './usePreventRemoveContext';
34
+ export { useRoute } from './useRoute';
35
+ export { validatePathConfig } from './validatePathConfig';
27
36
  export * from '@react-navigation/routers';
@@ -2,7 +2,7 @@
2
2
  * Compare two arrays with primitive values as the content.
3
3
  * We need to make sure that both values and order match.
4
4
  */
5
- export default function isArrayEqual(a: any[], b: any[]) {
5
+ export function isArrayEqual(a: any[], b: any[]) {
6
6
  if (a === b) {
7
7
  return true;
8
8
  }
@@ -1,10 +1,7 @@
1
1
  /**
2
2
  * Compare two records with primitive values as the content.
3
3
  */
4
- export default function isRecordEqual(
5
- a: Record<string, any>,
6
- b: Record<string, any>
7
- ) {
4
+ export function isRecordEqual(a: Record<string, any>, b: Record<string, any>) {
8
5
  if (a === b) {
9
6
  return true;
10
7
  }
package/src/types.tsx CHANGED
@@ -171,7 +171,7 @@ type NavigationHelpersCommon<
171
171
  * @param action Action object or update function.
172
172
  */
173
173
  dispatch(
174
- action: NavigationAction | ((state: State) => NavigationAction)
174
+ action: NavigationAction | ((state: Readonly<State>) => NavigationAction)
175
175
  ): void;
176
176
 
177
177
  /**
@@ -181,7 +181,7 @@ type NavigationHelpersCommon<
181
181
  * @param [params] Params object for the route.
182
182
  */
183
183
  navigate<RouteName extends keyof ParamList>(
184
- ...args: // this first condition allows us to iterate over a union type
184
+ ...args: // This condition allows us to iterate over a union type
185
185
  // This is to avoid getting a union of all the params from `ParamList[RouteName]`,
186
186
  // which will get our types all mixed up if a union RouteName is passed in.
187
187
  RouteName extends unknown
@@ -198,18 +198,56 @@ type NavigationHelpersCommon<
198
198
  /**
199
199
  * Navigate to a route in current navigation tree.
200
200
  *
201
- * @param route Object with `key` or `name` for the route to navigate to, and a `params` object.
201
+ * @param route Object with `name` for the route to navigate to, and a `params` object.
202
202
  */
203
203
  navigate<RouteName extends keyof ParamList>(
204
204
  options: RouteName extends unknown
205
- ?
206
- | { key: string; params?: ParamList[RouteName]; merge?: boolean }
207
- | {
208
- name: RouteName;
209
- key?: string;
210
- params: ParamList[RouteName];
211
- merge?: boolean;
212
- }
205
+ ? {
206
+ name: RouteName;
207
+ params: ParamList[RouteName];
208
+ path?: string;
209
+ merge?: boolean;
210
+ }
211
+ : never
212
+ ): void;
213
+
214
+ /**
215
+ * Navigate to a route in current navigation tree.
216
+ *
217
+ * @deprecated Use `navigate` instead.
218
+ *
219
+ * @param name Route name of the route.
220
+ * @param [params] Params object for the route.
221
+ */
222
+ navigateDeprecated<RouteName extends keyof ParamList>(
223
+ ...args: // This condition allows us to iterate over a union type
224
+ // This is to avoid getting a union of all the params from `ParamList[RouteName]`,
225
+ // which will get our types all mixed up if a union RouteName is passed in.
226
+ RouteName extends unknown
227
+ ? // This condition checks if the params are optional,
228
+ // which means it's either undefined or a union with undefined
229
+ undefined extends ParamList[RouteName]
230
+ ?
231
+ | [screen: RouteName] // if the params are optional, we don't have to provide it
232
+ | [screen: RouteName, params: ParamList[RouteName]]
233
+ : [screen: RouteName, params: ParamList[RouteName]]
234
+ : never
235
+ ): void;
236
+
237
+ /**
238
+ * Navigate to a route in current navigation tree.
239
+ *
240
+ * @deprecated Use `navigate` instead.
241
+ *
242
+ * @param route Object with `name` for the route to navigate to, and a `params` object.
243
+ */
244
+ navigateDeprecated<RouteName extends keyof ParamList>(
245
+ options: RouteName extends unknown
246
+ ? {
247
+ name: RouteName;
248
+ params: ParamList[RouteName];
249
+ merge?: boolean;
250
+ }
213
251
  : never
214
252
  ): void;
215
253
 
@@ -285,17 +323,25 @@ export type NavigationContainerProps = {
285
323
  /**
286
324
  * Callback which is called with the latest navigation state when it changes.
287
325
  */
288
- onStateChange?: (state: NavigationState | undefined) => void;
326
+ onStateChange?: (state: Readonly<NavigationState> | undefined) => void;
327
+ /**
328
+ * Callback which is called after the navigation tree mounts.
329
+ */
330
+ onReady?: () => void;
289
331
  /**
290
332
  * Callback which is called when an action is not handled.
291
333
  */
292
- onUnhandledAction?: (action: NavigationAction) => void;
334
+ onUnhandledAction?: (action: Readonly<NavigationAction>) => void;
293
335
  /**
294
- * Whether this navigation container should be independent of parent containers.
295
- * If this is not set to `true`, this container cannot be nested inside another container.
296
- * Setting it to `true` disconnects any children navigators from parent container.
336
+ * Whether child navigator should handle a navigation action.
337
+ * The child navigator needs to be mounted before it can handle the action.
338
+ * Defaults to `false`.
339
+ *
340
+ * This will be removed in the next major release.
341
+ *
342
+ * @deprecated Use nested navigation API instead
297
343
  */
298
- independent?: boolean;
344
+ navigationInChildEnabled?: boolean;
299
345
  /**
300
346
  * Children elements to render.
301
347
  */
@@ -335,7 +381,7 @@ export type NavigationProp<
335
381
  * Update the options for the route.
336
382
  * The options object will be shallow merged with default options object.
337
383
  *
338
- * @param options Options object for the route.
384
+ * @param update Options object or a callback which takes the options from navigator config and returns a new options object.
339
385
  */
340
386
  setOptions(options: Partial<ScreenOptions>): void;
341
387
  } & EventConsumer<EventMap & EventMapCore<State>> &
@@ -372,11 +418,9 @@ export type CompositeNavigationProp<
372
418
  */
373
419
  A extends NavigationProp<any, any, any, infer S> ? S : NavigationState,
374
420
  /**
375
- * Screen options from both navigation objects needs to be combined
376
- * This allows typechecking `setOptions`
421
+ * Screen options should refer to the options specified in the first type
377
422
  */
378
- (A extends NavigationProp<any, any, any, any, infer O> ? O : {}) &
379
- (B extends NavigationProp<any, any, any, any, infer P> ? P : {}),
423
+ A extends NavigationProp<any, any, any, any, infer O> ? O : {},
380
424
  /**
381
425
  * Event consumer config should refer to the config specified in the first type
382
426
  * This allows typechecking `addListener`/`removeListener`
@@ -527,7 +571,11 @@ export type RouteConfig<
527
571
  * For a given screen name, there will always be only one screen corresponding to an ID.
528
572
  * If `undefined` is returned, it acts same as no `getId` being specified.
529
573
  */
530
- getId?: ({ params }: { params: ParamList[RouteName] }) => string | undefined;
574
+ getId?: ({
575
+ params,
576
+ }: {
577
+ params: Readonly<ParamList[RouteName]>;
578
+ }) => string | undefined;
531
579
 
532
580
  /**
533
581
  * Initial params object for the route.
@@ -661,16 +709,13 @@ export type TypedNavigator<
661
709
  ) => null;
662
710
  };
663
711
 
664
- export type NavigatorScreenParams<
665
- ParamList,
666
- State extends NavigationState = NavigationState
667
- > =
712
+ export type NavigatorScreenParams<ParamList extends {}> =
668
713
  | {
669
714
  screen?: never;
670
715
  params?: never;
671
716
  initial?: never;
672
717
  path?: string;
673
- state: PartialState<State> | State | undefined;
718
+ state: PartialState<NavigationState> | NavigationState | undefined;
674
719
  }
675
720
  | {
676
721
  [RouteName in keyof ParamList]: undefined extends ParamList[RouteName]
@@ -691,18 +736,55 @@ export type NavigatorScreenParams<
691
736
  }[keyof ParamList];
692
737
 
693
738
  export type PathConfig<ParamList extends {}> = {
739
+ /**
740
+ * Path string to match against.
741
+ * e.g. `/users/:id` will match `/users/1` and extract `id` param as `1`.
742
+ */
694
743
  path?: string;
744
+ /**
745
+ * Whether the path should be consider parent paths or use the exact path.
746
+ * By default, paths are relating to the path config on the parent screen.
747
+ * If `exact` is set to `true`, the parent path configuration is not used.
748
+ */
695
749
  exact?: boolean;
750
+ /**
751
+ * An object mapping the param name to a function which parses the param value.
752
+ *
753
+ * @example
754
+ * ```js
755
+ * parse: {
756
+ * id: Number,
757
+ * date: (value) => new Date(value)
758
+ * }
759
+ * ```
760
+ */
696
761
  parse?: Record<string, (value: string) => any>;
762
+ /**
763
+ * An object mapping the param name to a function which converts the param value to a string.
764
+ * By default, all params are converted to strings using `String(value)`.
765
+ *
766
+ * @example
767
+ * ```js
768
+ * stringify: {
769
+ * date: (value) => value.toISOString()
770
+ * }
771
+ * ```
772
+ */
697
773
  stringify?: Record<string, (value: any) => string>;
774
+ /**
775
+ * Path configuration for child screens.
776
+ */
698
777
  screens?: PathConfigMap<ParamList>;
778
+ /**
779
+ * Name of the initial route to use for the navigator when the path matches.
780
+ */
699
781
  initialRouteName?: keyof ParamList;
700
782
  };
701
783
 
702
784
  export type PathConfigMap<ParamList extends {}> = {
703
785
  [RouteName in keyof ParamList]?: NonNullable<
704
786
  ParamList[RouteName]
705
- > extends NavigatorScreenParams<infer T, any>
787
+ > extends NavigatorScreenParams<infer T>
706
788
  ? string | PathConfig<T>
707
789
  : string | Omit<PathConfig<{}>, 'screens' | 'initialRouteName'>;
708
790
  };
@@ -5,7 +5,7 @@ import type { ListenerMap } from './NavigationBuilderContext';
5
5
  /**
6
6
  * Hook which lets child navigators add action listeners.
7
7
  */
8
- export default function useChildListeners() {
8
+ export function useChildListeners() {
9
9
  const { current: listeners } = React.useRef<{
10
10
  [K in keyof ListenerMap]: ListenerMap[K][];
11
11
  }>({
@@ -11,7 +11,7 @@ const NavigationContent = ({ render, children }: Props) => {
11
11
  return render(children);
12
12
  };
13
13
 
14
- export default function useComponent(render: Render) {
14
+ export function useComponent(render: Render) {
15
15
  const renderRef = React.useRef<Render | null>(render);
16
16
 
17
17
  // Normally refs shouldn't be mutated in render
@@ -1,7 +1,7 @@
1
1
  import type { NavigationState, ParamListBase } from '@react-navigation/routers';
2
2
  import * as React from 'react';
3
3
 
4
- import CurrentRenderContext from './CurrentRenderContext';
4
+ import { CurrentRenderContext } from './CurrentRenderContext';
5
5
  import type {
6
6
  Descriptor,
7
7
  NavigationHelpers,
@@ -22,11 +22,7 @@ type Options = {
22
22
  * Write the current options, so that server renderer can get current values
23
23
  * Mutating values like this is not safe in async mode, but it doesn't apply to SSR
24
24
  */
25
- export default function useCurrentRender({
26
- state,
27
- navigation,
28
- descriptors,
29
- }: Options) {
25
+ export function useCurrentRender({ state, navigation, descriptors }: Options) {
30
26
  const current = React.useContext(CurrentRenderContext);
31
27
 
32
28
  if (current && navigation.isFocused()) {
@@ -6,13 +6,14 @@ import type {
6
6
  } from '@react-navigation/routers';
7
7
  import * as React from 'react';
8
8
 
9
- import NavigationBuilderContext, {
9
+ import {
10
10
  AddKeyedListener,
11
11
  AddListener,
12
+ NavigationBuilderContext,
12
13
  } from './NavigationBuilderContext';
13
- import NavigationContext from './NavigationContext';
14
- import NavigationRouteContext from './NavigationRouteContext';
15
- import SceneView from './SceneView';
14
+ import { NavigationContext } from './NavigationContext';
15
+ import { NavigationRouteContext } from './NavigationRouteContext';
16
+ import { SceneView } from './SceneView';
16
17
  import type {
17
18
  Descriptor,
18
19
  EventMapBase,
@@ -22,8 +23,8 @@ import type {
22
23
  RouteProp,
23
24
  } from './types';
24
25
  import type { NavigationEventEmitter } from './useEventEmitter';
25
- import useNavigationCache from './useNavigationCache';
26
- import useRouteCache from './useRouteCache';
26
+ import { useNavigationCache } from './useNavigationCache';
27
+ import { useRouteCache } from './useRouteCache';
27
28
 
28
29
  export type ScreenConfigWithParent<
29
30
  State extends NavigationState,
@@ -79,7 +80,7 @@ type Options<
79
80
  * - Options specified by the screen for the navigator
80
81
  * - Navigation object intended for the route
81
82
  */
82
- export default function useDescriptors<
83
+ export function useDescriptors<
83
84
  State extends NavigationState,
84
85
  ActionHelpers extends Record<string, () => void>,
85
86
  ScreenOptions extends {},
@@ -99,7 +100,9 @@ export default function useDescriptors<
99
100
  router,
100
101
  emitter,
101
102
  }: Options<State, ScreenOptions, EventMap>) {
102
- const [options, setOptions] = React.useState<Record<string, object>>({});
103
+ const [options, setOptions] = React.useState<Record<string, ScreenOptions>>(
104
+ {}
105
+ );
103
106
  const { onDispatchAction, onOptionsChange, stackRef } = React.useContext(
104
107
  NavigationBuilderContext
105
108
  );
@@ -177,6 +180,7 @@ export default function useDescriptors<
177
180
  (acc, curr) =>
178
181
  Object.assign(
179
182
  acc,
183
+ // @ts-expect-error: we check for function but TS still complains
180
184
  typeof curr !== 'function' ? curr : curr({ route, navigation })
181
185
  ),
182
186
  {} as ScreenOptions
@@ -205,29 +209,31 @@ export default function useDescriptors<
205
209
  return o;
206
210
  });
207
211
 
212
+ const element = (
213
+ <NavigationBuilderContext.Provider key={route.key} value={context}>
214
+ <NavigationContext.Provider value={navigation}>
215
+ <NavigationRouteContext.Provider value={route}>
216
+ <SceneView
217
+ navigation={navigation}
218
+ route={route}
219
+ screen={screen}
220
+ routeState={state.routes[i].state}
221
+ getState={getState}
222
+ setState={setState}
223
+ options={mergedOptions}
224
+ clearOptions={clearOptions}
225
+ />
226
+ </NavigationRouteContext.Provider>
227
+ </NavigationContext.Provider>
228
+ </NavigationBuilderContext.Provider>
229
+ );
230
+
208
231
  acc[route.key] = {
209
232
  route,
210
233
  // @ts-expect-error: it's missing action helpers, fix later
211
234
  navigation,
212
235
  render() {
213
- return (
214
- <NavigationBuilderContext.Provider key={route.key} value={context}>
215
- <NavigationContext.Provider value={navigation}>
216
- <NavigationRouteContext.Provider value={route}>
217
- <SceneView
218
- navigation={navigation}
219
- route={route}
220
- screen={screen}
221
- routeState={state.routes[i].state}
222
- getState={getState}
223
- setState={setState}
224
- options={mergedOptions}
225
- clearOptions={clearOptions}
226
- />
227
- </NavigationRouteContext.Provider>
228
- </NavigationContext.Provider>
229
- </NavigationBuilderContext.Provider>
230
- );
236
+ return element;
231
237
  },
232
238
  options: mergedOptions as ScreenOptions,
233
239
  };
@@ -12,7 +12,7 @@ type Listeners = ((e: any) => void)[];
12
12
  /**
13
13
  * Hook to manage the event system used by the navigator to notify screens of various events.
14
14
  */
15
- export default function useEventEmitter<T extends Record<string, any>>(
15
+ export function useEventEmitter<T extends Record<string, any>>(
16
16
  listen?: (e: any) => void
17
17
  ): NavigationEventEmitter<T> {
18
18
  const listenRef = React.useRef(listen);
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
 
3
- import useNavigation from './useNavigation';
3
+ import { useNavigation } from './useNavigation';
4
4
 
5
5
  type EffectCallback = () => undefined | void | (() => void);
6
6
 
@@ -11,7 +11,7 @@ type EffectCallback = () => undefined | void | (() => void);
11
11
  *
12
12
  * @param callback Memoized callback containing the effect, should optionally return a cleanup function.
13
13
  */
14
- export default function useFocusEffect(effect: EffectCallback) {
14
+ export function useFocusEffect(effect: EffectCallback) {
15
15
  const navigation = useNavigation();
16
16
 
17
17
  if (arguments[1] !== undefined) {
@@ -1,7 +1,7 @@
1
1
  import type { NavigationState } from '@react-navigation/routers';
2
2
  import * as React from 'react';
3
3
 
4
- import NavigationContext from './NavigationContext';
4
+ import { NavigationContext } from './NavigationContext';
5
5
  import type { EventMapCore } from './types';
6
6
  import type { NavigationEventEmitter } from './useEventEmitter';
7
7
 
@@ -13,7 +13,7 @@ type Options<State extends NavigationState> = {
13
13
  /**
14
14
  * Hook to take care of emitting `focus` and `blur` events.
15
15
  */
16
- export default function useFocusEvents<State extends NavigationState>({
16
+ export function useFocusEvents<State extends NavigationState>({
17
17
  state,
18
18
  emitter,
19
19
  }: Options<State>) {
@@ -1,9 +1,10 @@
1
1
  import type { ParamListBase } from '@react-navigation/routers';
2
2
  import * as React from 'react';
3
3
 
4
- import NavigationBuilderContext, {
4
+ import {
5
5
  FocusedNavigationCallback,
6
6
  FocusedNavigationListener,
7
+ NavigationBuilderContext,
7
8
  } from './NavigationBuilderContext';
8
9
  import type { NavigationHelpers } from './types';
9
10
 
@@ -15,7 +16,7 @@ type Options = {
15
16
  /**
16
17
  * Hook for passing focus callback to children
17
18
  */
18
- export default function useFocusedListenersChildrenAdapter({
19
+ export function useFocusedListenersChildrenAdapter({
19
20
  navigation,
20
21
  focusedListeners,
21
22
  }: Options) {
@@ -1,13 +1,13 @@
1
1
  import * as React from 'react';
2
2
  import { useState } from 'react';
3
3
 
4
- import useNavigation from './useNavigation';
4
+ import { useNavigation } from './useNavigation';
5
5
 
6
6
  /**
7
7
  * Hook to get the current focus state of the screen. Returns a `true` if screen is focused, otherwise `false`.
8
8
  * This can be used if a component needs to render something based on the focus state.
9
9
  */
10
- export default function useIsFocused(): boolean {
10
+ export function useIsFocused(): boolean {
11
11
  const navigation = useNavigation();
12
12
  const [isFocused, setIsFocused] = useState(navigation.isFocused);
13
13
 
@@ -5,7 +5,7 @@ import type { KeyedListenerMap } from './NavigationBuilderContext';
5
5
  /**
6
6
  * Hook which lets child navigators add getters to be called for obtaining rehydrated state.
7
7
  */
8
- export default function useKeyedChildListeners() {
8
+ export function useKeyedChildListeners() {
9
9
  const { current: keyedListeners } = React.useRef<{
10
10
  [K in keyof KeyedListenerMap]: Record<
11
11
  string,
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
 
3
- import NavigationContainerRefContext from './NavigationContainerRefContext';
4
- import NavigationContext from './NavigationContext';
3
+ import { NavigationContainerRefContext } from './NavigationContainerRefContext';
4
+ import { NavigationContext } from './NavigationContext';
5
5
  import type { NavigationProp } from './types';
6
6
 
7
7
  /**
@@ -9,7 +9,7 @@ import type { NavigationProp } from './types';
9
9
  *
10
10
  * @returns Navigation prop of the parent screen.
11
11
  */
12
- export default function useNavigation<
12
+ export function useNavigation<
13
13
  T = NavigationProp<ReactNavigation.RootParamList>
14
14
  >(): T {
15
15
  const root = React.useContext(NavigationContainerRefContext);