This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect, useRef } from 'react'; | |
// Usage | |
function App() { | |
// Create a ref that we add to the element for which we want to detect outside clicks | |
// State for our modal | |
const [isModalOpen, setModalOpen] = useState(false); | |
// Call hook passing in the ref and a function to call on outside click | |
const ref = useOnClickOutside(() => setModalOpen(false)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
$("#controls > div").hide(); | |
$('<canvas id="viewport" width="140" height="65">') | |
.css("float", "left") | |
.appendTo("#controls"); | |
$("<button />", { | |
text: "Show", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
$("#controls > div").hide(); | |
$('<canvas id="viewport" width="140" height="65">') | |
.css("float", "left") | |
.appendTo("#controls"); | |
$("<button />", { | |
text: "Show", |