document.getElementById('pwMeter').style.display='none' not working as expected


I’m trying to hide a div using the following method in a react web page. But it doesn’t hide the element. I can’t see any errors in the developer tools as well.


What is the problem here? Does React support this method?


yes with react you can do this , check this sample ref code for that

import { useState } from "react";

const TestFunction = (props) => {
  const [pw, setpw] = useState(["test"]);
  return (
        style={pw && pw.length > 0 ? { display: "bock" } : { display: "none" }}
        <p>test data</p>

export default TestFunction;

Answered By – Darshan

Answer Checked By – Marilyn (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.