OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to send data from multiple screen to one single screen in React native

  • Thread starter Thread starter jACOB Alex
  • Start date Start date
J

jACOB Alex

Guest
i have basically four screens and i am sending the data to other screen. for example i am sending the data from Home to ListScreen with some items from flatlist then i am also sending the other data from SearchScreen to ListScreen but problem here in when i go to ListScreen from TabScreen or then it gives me error on {item.name}

Code:
 <TouchableOpacity onPress={() => navigation.navigate(MainScreens.ListScreen, {
                     item: item, 
                     })} >
                       
                </TouchableOpacity>
and there also

Code:
<TouchableOpacity onPress={() => navigation.navigate(MainScreens.ListScreen, {
                     item: item, 
                     totalFixed: totalPrice,
                     })} >
                       
                </TouchableOpacity>
my question is how can i differentiate them in ListScreen how can i came to know that these both data are different from each other

Code:
export const ListScreen: React.FC<ListScreenProps> = ({ route, navigation }) => {
    const { item, totalFixed } = route.params || {};
here i have two types of object in item item.name and item.category but i get error below here i have error that item.price not found because i came with home screen.

Code:
 <Text >Total: AED {item.price}</Text>

<blockquote>
<p>i have basically four screens and i am sending the data to other
screen. for example i am sending the data from <strong>Home to ListScreen</strong> with
some items from <strong>flatlist</strong> then i am also sending the other data from
<strong>SearchScreen to ListScreen</strong> but problem here in when i go to
<strong>ListScreen from TabScreen</strong> or then it gives me error on <strong>{item.name}</strong></p>
</blockquote>
<pre><code> <TouchableOpacity onPress={() => navigation.navigate(MainScreens.ListScreen, {
item: item,
})} >

</TouchableOpacity>
</code></pre>
<blockquote>
<p>and there also</p>
</blockquote>
<pre><code><TouchableOpacity onPress={() => navigation.navigate(MainScreens.ListScreen, {
item: item,
totalFixed: totalPrice,
})} >

</TouchableOpacity>
</code></pre>
<blockquote>
<p>my question is how can i differentiate them in ListScreen how can i
came to know that these both data are different from each other</p>
</blockquote>
<pre><code>export const ListScreen: React.FC<ListScreenProps> = ({ route, navigation }) => {
const { item, totalFixed } = route.params || {};
</code></pre>
<blockquote>
<p>here i have two types of object in item <strong>item.name</strong> and
<strong>item.category</strong> but i get error
below here i have error that <strong>item.price</strong> not found because i came with home screen.</p>
</blockquote>
<pre><code> <Text >Total: AED {item.price}</Text>
</code></pre>
 

Latest posts

H
Replies
0
Views
1
hohohohoho
H
Top