Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jamiejohnsonkc/d00dea1ca7979d5268d23a24cc2ea3fb to your computer and use it in GitHub Desktop.

Select an option

Save jamiejohnsonkc/d00dea1ca7979d5268d23a24cc2ea3fb to your computer and use it in GitHub Desktop.
hide div using react hooks useState button
/** @jsx jsx */
import { jsx, Container } from "theme-ui"
import React, { useState } from "react"
function Demo2() {
const [isVisible, setIsVisible] = useState(true)
return (
<div style={{ display: isVisible ? "block" : "none" }}>
<p>This is the visibilityi test div</p>
<button onClick={() => setIsVisible(false)}>Click me</button>
</div>
)
}
export default Demo2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment