-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Current behavior
When using a nested StackNavigator and navigating from a screen to another in it, I get an error : [TypeError: Cannot add new property 'CONSUMED_PARAMS'] coming from there :
| Object.defineProperty(route.params, CONSUMED_PARAMS, { |
It appears that sometimes, the
route.params object is not exetensible, probably sealed or freezed. I can't figure exactly why.
My navigation structure :
StackNavigator (App) :
|__ Signup : SignupNavigator _(receives route.params { context: "whatever" })_
|__ SignupUsername
|__ SignupPicture
|__ ...
|__ ...
When navigating from SignupUsername to SignupPicture, via the (SignupNavigator's) navigation navigate function, with params, like this : navigation.navigate("Signup", { context: SignupContext.WHATEVER }, { pop: true }), it appears that the route.params object in useNavigationBuilder becomes non-extensible.
To patch it quickly, I will add a Object.isExtensible(route.params) check on my own. But I wonder if it is a stable solution or if I'm doing something wrong in my use of React Navigation.
Expected behavior
Get no error
Reproduction
https://github.com/react-navigation/react-navigation/issues
Platform
- Android
- iOS
- Web
- Windows
- MacOS
Packages
- @react-navigation/bottom-tabs
- @react-navigation/drawer
- @react-navigation/material-top-tabs
- @react-navigation/stack
- @react-navigation/native-stack
- react-native-drawer-layout
- react-native-tab-view
Environment
- I've removed the packages that I don't use
| package | version |
|---|---|
| @react-navigation/native | |
| @react-navigation/material-top-tabs | |
| @react-navigation/stack | |
| @react-navigation/native-stack | |
| react-native-tab-view | |
| react-native-screens | |
| react-native-safe-area-context | |
| react-native-gesture-handler | |
| react-native-reanimated | |
| react-native-pager-view | |
| react-native | |
| expo | |
| node | |
| npm or yarn |