Passing parameters images to routes

I am designing a project to book vacations and I created a component in which I display an image of the beach and it has 2 props, which is {price, image} in this way

When you click on it, go to a screen that I designed to display the image of the beach and its price … But here is the problem … Whenever I click on any beach, the image of the beach comes to me and the price is fixed without changing

I want to change this following code in the beach screen … because I want when I click on the first beach, its image and price will appear to me … and when I click on the second, its image and price appear to me … and when I click on the third, its image and price appear to me … instead of this fixed image and price Constant

I hope for help please

Hi Ahmed - I know this is a little bit late, but usually when you’re trying to trace if data is being properly passed between components, you need to look at “props”. (In my experience, this is significantly easier to do on Web, like just using create-react-app for example, than it is on iOS or Android.)

Based on your screenshots and description, I think you may need to read some docs about how a component receives and controls data - “props” and “state”. In your second screenshot, the component is not using dynamic data (“props” or “state”) at all. You have it hardcoded to use 20$, “Ahmed Al SAwy”, and “/beachs/2.jpg”, so those values will be used every time.

By the way, your specific question might be confused with terms related to routing (like different URLs). I think a more appropriate question would be something like “How to pass parameters to a child component?” and is actually a very general React question.

Hope this helps, hope you have an overall good experience with Expo/React!

1 Like