我陷入了一個問題,我必須按下(onPress)一個按鈕,這必須創建一個新組件。就像一個待辦事項串列。但是,我不知道如何才能解決這個問題。
uj5u.com熱心網友回復:
你可以看看很多待辦事項應用程式,以獲得更好的想法,但一般來說,解決方案是一個具有串列狀態的組件,為串列中的每個專案渲染一個元素。
const Comp = (/span>) => {
const [todos, setTodos] = useState(["first"/span>])。
return <>/span>
{todos.map(t => <Row>
onPress={()=> setTodos([...todos, Math.random().toString() ])
>
{t}
</Row>) }
</>。
};
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/332288.html
標籤:
