skip to Main Content

react native useState update

I have this : const [debugStr, setDebugStr] = useState("This is a debug string") function debug(str){ setDebugStr(str+'nn'+debugStr) } function testPressed(){ debug("Test1") debug("Test2") } // and later : <Button onPress={() => { testPressed() }} title='Press me' /> <Text>{debugStr}</Text> My problem is that…

VIEW QUESTION

Reactjs – React: 'map' function

I'm fetching a list of objects. Using map function should display a list but there wasn't. I checked if it was saved to 'useState' via console.log(posts), and yes there was a list of objects. My only problem is I cant…

VIEW QUESTION

Javascript – Weird behviour when trying to update an array in reactjs

import { useRef, useState } from "react"; import "./styles.css"; export default function App() { const [array, setArray] = useState(["apple", "mango", "strawberry"]); console.log("outside", array, Date.now()); function update(e) { const name = document.getElementById("name").value; const pos = Number(document.getElementById("pos").value); setArray((prev) => { console.log("prev ===>",…

VIEW QUESTION
Back To Top
Search