DEV Community

Anjali Gurjar
Anjali Gurjar

Posted on

React Interview

import {useState,useEffect} from 'react'

const FakeApi=() => new Promise((resolve)=>{
setTimeout(()=>{
resolve([{
id:1,
name:"ANjali",
age:12,

    },
             {
                 id:1,
        name:"Addu",
        age:12,
             }
            ])
},3000)
Enter fullscreen mode Exit fullscreen mode

});

export default function App() {

const [data,setdata]=useState([]);
useEffect(()=>{
const fetchresult=async()=>{
const result=await FakeApi()
setdata(result)

}
fetchresult()
Enter fullscreen mode Exit fullscreen mode

},[])

return (

























{data.map((item) => {

return (



)

})}




id name age
{item.id} {item.name} {item.age}




)

}

Top comments (0)