Skip to content

Conversation

marklawlor
Copy link
Contributor

@marklawlor marklawlor commented May 22, 2025

Why

useRootNavigationState currently errors with Warning: TypeError: Cannot read property 'getState' of undefined when used in the root layout

How

Changed to navigation = navigation.getParent(INTERNAL_SLOT_NAME) || navigation;. If there is no parent INTERNAL_SLOT_NAME then we are in the root navigator.

Test Plan

Added unit tests for useRootNavigationState

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label May 22, 2025
@marklawlor marklawlor force-pushed the marklawlor/sdk-53/fix-useRootNavigationState-root-layout branch from 3d3198e to 9f4ef05 Compare May 22, 2025 06:04
@marklawlor marklawlor marked this pull request as ready for review May 22, 2025 06:04
Copy link
Contributor

Subscribed to pull request

File Patterns Mentions
packages/expo-router/** @EvanBacon

Generated by CodeMention

@marklawlor marklawlor force-pushed the marklawlor/sdk-53/fix-useRootNavigationState-root-layout branch from 9f4ef05 to 1b6d9c8 Compare May 22, 2025 06:10
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels May 22, 2025
@marklawlor marklawlor force-pushed the marklawlor/sdk-53/fix-useRootNavigationState-root-layout branch from 1b6d9c8 to f7c2fab Compare May 22, 2025 06:41
@marklawlor marklawlor force-pushed the marklawlor/sdk-53/fix-useRootNavigationState-root-layout branch from f7c2fab to ca22265 Compare May 26, 2025 08:13
@marklawlor marklawlor merged commit 8baac7e into main May 26, 2025
20 of 22 checks passed
@marklawlor marklawlor deleted the marklawlor/sdk-53/fix-useRootNavigationState-root-layout branch May 26, 2025 08:58
marklawlor added a commit that referenced this pull request May 26, 2025
…37023)

# Why

`useRootNavigationState` currently errors with `Warning: TypeError:
Cannot read property 'getState' of undefined` when used in the root
layout

# How

Changed to `navigation = navigation.getParent(INTERNAL_SLOT_NAME) ||
navigation;`. If there is no parent `INTERNAL_SLOT_NAME` then we are in
the root navigator.

# Test Plan

Added unit tests for `useRootNavigationState`
@Gitarcitano
Copy link

@marklawlor Do you have an estimated release date for the version containing this fix?
Without it, I believe many projects are still unable to migrate from SDK 52 to 53 (it's a blocker for me).

@gabrieldonadel gabrieldonadel added the published Changes from the PR have been published to npm label Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: fingerprint compatible bot: passed checks ExpoBot has nothing to complain about published Changes from the PR have been published to npm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants