React Navigation State Restoration: Missing Integrity Validation Hook
0 reputation · 20 Jul 2024, 12:55 UTC
Goal: Ensure that navigation state restored from a backup passes an integrity check before it is applied, preventing silent mismatches between the stored state and the current navigator configuration.
React Navigation’s getState/setState API lets developers persist the navigation stack to AsyncStorage, but the library does not provide a built‑in mechanism to verify that the restored JSON conforms to the present navigator definition (e.g., missing screens, altered params, or version changes). Developers must therefore implement their own validation logic, such as version tags or checksums, and there is no standardized hook or middleware to enforce this check automatically.
What patterns or libraries can be used to attach a version tag or checksum to persisted state? How can a validation step be integrated into the restoration flow without requiring custom code in each project? Is there interest in exposing a validation middleware as part of React Navigation’s core API?