Updating a global variable from within a function

Solution 1:

You should be using useState in react to store your variables. how to use

Creating

const [information, setInformation] = useState(null);

Updateing

setInformation({
  name: searchResponse.results[num].name,
  open_now: searchResponse.results[num].opening_hours.open_now,
  rating: searchResponse.results[num].rating,
  price: searchResponse.results[num].price_level
})

Then passing the state to props should stay the same.

<Result info={information} />