import './App.css' ; import React ,{ useState } from "react" ; function App (){ //setInterval ( updateTime , 1000 ) //1000 is sec //this is a function by javascript const now = new Date (). toLocaleTimeString (); const [ time , setTime ] = useState ( now ); // first wla variable and 2nd wala function ever time useState me kuch hona chiya phela function updateTime (){ const newTime = new Date (). toLocaleTimeString (); //variable setTime ( newTime ); } return ( < div className = "container" > < h1 > { time } </ h1 > < button onClick = { updateTime } > GetTime </ button > </ div > ) } ...
in react map function every element is going in a loop and the element or components should be in array [] like [ ] we can call function under function or we say that call function under map function we can write map function let a = [12,3,4,5,5]; const no = a.map(function(x){ return x*2; } ); console.log(no); and also function n(x){ return x*2; }
Comments
Post a Comment