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}




)

}

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay