Views: 1

function App() {

  // How to check if an Object is Empty in React

  const [persone, setPerson] = useState({})

  useEffect(() => {
    if(Object.keys(persone).length === 0) {
      console.log("obect is empty")
    }

    if(Object.keys(persone).length > 0) {
      console.log("obect is not empty")
    }
   
  }, [persone])
  

 

  return (
    

{JSON.stringify(persone)}

); }

YouTube Video

check if object is empty React js

Let us know if you liked the post. That’s the only way we can improve.



Credit goes to the respective owner!

Leave a Reply

Your email address will not be published. Required fields are marked *