El estilo dentro del div crea un cuadro rojo. Al hacer clic quiero eliminarlo. Intenté implementar el estado pero no funcionó.
import React, { Component } from "react"; class ClickMe extends Component { render() { return ( <div> <h1>Disapearing Box</h1> <h3>Click the Box, I dare you</h3> <div style={{ height: "400px", width: "400px", background: "#ef8989", margin: "auto", }} ></div> </div> ); } } export default ClickMe; ); } } export default ClickMe;intentalo:
import React, { useState } from "react"; const ClickMe =() => { const [active, setActive] = useState(false) return ( <div onClick={() => setActive(!active)}> <h1>Disapearing Box</h1> <h3>Click the Box, I dare you</h3> <div style={{ height: "400px", width: "400px", background: active ? "none" : "#ef8989", margin: "auto", }} ></div> </div> ); } export default ClickMe;