Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react native getting old navigation parameter

The problem here is how navigation.navigate works. If you use it without
passing the key for the next screen, react-navigation won't match it with the 
screen that is already mounted hence mounting another one.

What you can observe here is exactly the case when the component was not yet 
unmounted but navigate doesn't know that and renders another instance of the 
same component.

You can prevent this by passing the key param into navigate function as follows:

navigation.navigate({name: 'ScreenB', key: 'ScreenB', params: { id: 1}})

navigation.navigate({name: 'ScreenB', key: 'ScreenB', params: { id: 2}})

Now StackNavigator can check if screen with the same key already exists and 
prevent it from mounting.
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript get script path name 
Javascript :: javascript auto detect if select input changed 
Javascript :: react router 6 redirect 
Javascript :: jquery code to javascript converter 
Javascript :: rename data table button 
Javascript :: span element converink href="plugins/jvectormap/jquery-jvectormap-1.2.2.css" rel="stylesheet" type="text/css" / <!-- Date Picker --ter 
Javascript :: jeebisah 
Javascript :: Cache and return requests 
Javascript :: how to send data from form with post axios in nuxt 
Javascript :: how to get current row value by clicking a button 
Javascript :: using nodejs cart price calculation 
Javascript :: spread operator shorthand javascript 
Javascript :: react js practical tutorial 
Javascript :: convert javascript to typescript online converter 
Javascript :: linux pupperteer 
Javascript :: Simple Email Validation, Case Insensitive, w/ All Valid Local Part Characters (whatever tf that means to you...), 2nd Example - Regex 
Javascript :: &lt;Link&gt; react import 
Javascript :: downlaod file from website raect2 
Javascript :: append to a div and save the previous data after refresh page in javascript 
Javascript :: what is the equivalent of cascade on delete in mongoose 
Javascript :: int[] arr = new int[5]; for(int i=0; i<arr.length; i++){ arr[i] = i; } for(int i=0; i<arr.length; i++) { System.out.print(arr[i]); } 
Javascript :: Private slots are new and can be created via Private methods and accessors 
Javascript :: binary conversion recursion in javascript 
Javascript :: custom validator Whitelisting 
Javascript :: why android folder size is 500mb in react native 
Javascript :: "date change error" 
Javascript :: adding values for metaboxes in wordpress 
Javascript :: format file using jq 
Javascript :: iteration methods 
Javascript :: how to get csrf token javascript document query selector 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =