我应该如何在 React JS 中使用函数的变量作为道具

How should I use a variable of a function as a prop in React JS

import React, { useState } from 'react'
import Display from './components/Display';
const App = () => {
    const [input,setInput] = useState("");
    
    const getData = async () => {
    const myAPI = await fetch(`http://api.openweathermap.org/data/2.5/weather?q=${input}&units=metric&appid=60dfee3eb8199cac3e55af5339fd0761`);
    const response = await myAPI.json();
    console.log(response);                  //want to use response as a prop in Display component
   }

   return(
    <div className="container">
        <h1>Weather Report</h1>
        <Display title={"City Name :"} />         //here
        <Display title={"Temperature :"} />       //here
        <Display title={"Description :"} />       //here
        <input type={input} onChange={e => setInput(e.target.value)} className="input"/>
        <button className="btn-style" onClick={getData}>Fetch</button>
    </div>
   );
}

export default App;

我不知道我对你的理解是否正确,但如果我是对的,你想访问从你的函数返回的数据,这些数据是从 API 获取的,如果是的话你可以尝试这种方式

import React, { useState, useEffect } from 'react' 
import Display from './components/Display';
import axios from 'axios';

const App = () => {
const [input,setInput] = useState(""); 

const [state, setState] = useState({loading: true, fetchedData: null});

useEffect(() => {
        getData();
}, [setState]);

async function getData() {
    setState({ loading: true });
    const apiUrl = 'http://api.openweathermap.org/data/2.5/weather?q=${input}&units=metric&appid=60dfee3eb8199cac3e55af5339fd0761';
    await axios.get(apiUrl).then((repos) => {
        const rData = repos.data;
        setState({ loading: false, fetchedData: rData });
    });
}

return(
    state.loading ? <CircularProgress /> : ( 
        <List className={classes.root}>
        { state.fetchedData.map((row) => ( 
            <div className="container">
                <h1>Weather Report</h1>
                <Display title={"City Name :" + row.cityName } />         //here
                <Display title={"Temperature :" + row.temperature} />       //here
                <Display title={"Description :" + row.description} />       //here
                 
            </div>
        )) }
        </List>
    )
);

}