skip to Main Content

I managed to update a PRODUCT value from the database, but I want to get the value now in the interface, so the user will see exactly the value from the database.

what I code;

data i found

console log

So if I console.log ITEM, I’m getting undefined and then data show after it said undefined here are the logs:

Please help me to solve this issue.

2

Answers


  1. U need to use async/await in your code which asynchronous operations like fetching data from a database which will give u the data once available

    Login or Signup to reply.
  2. Define smartPhone as a state:

    const [smartPhone, setSmartPhone] = useState([])
    
    useEffect(()=>{
     if(popular.length > 0) setSmartPhone(popular)
    },[popular])
    

    And return:

    {
       smartPhone.length > 0 && (
          smartPhone.map(
             // Your code...
          )
       )
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search