import React from "react"; import "./editthispage.css"; export function EditThisPage({ source }) { const [opening, setOpening] = React.useState(false); React.useEffect(() => { let dismounted = false; if (opening) { setTimeout(() => { if (!dismounted) { setOpening(false); } }, 3000); } }, [opening]); function openInEditorHandler(event) { event.preventDefault(); const filepath = source.content_file; console.log(`Going to try to open ${filepath} in your editor`); setOpening(true); fetch(`/_open?filepath=${filepath}`); // .then(r => { // console.log("R", r); // }) // .catch(ex => { // console.log("EX:", ex); // }); } if (!source) { return null; } if (source.github_url) { return (

Edit this page in GitHub

); } else if (source.content_file) { return (

Edit this page in your editor
{opening && Trying to your editor now...}

); } else { throw new Error("source has neither .github_url or .content_file"); } }