refactor: add typescript support to project

This commit is contained in:
HD
2022-06-21 15:08:35 +08:00
parent 88ec2b742a
commit bd799ebea8
259 changed files with 1042 additions and 458 deletions
@@ -0,0 +1,29 @@
import { useState, useEffect } from "react";
import styled from "styled-components";
const Styled = styled.div`
height: 218px;
padding: 15px 15px 0 15px;
line-height: 1.4;
overflow: scroll;
white-space: pre-wrap;
word-break: break-all;
background-color: #000;
color: #eee;
`;
export default function Code({ url = "" }) {
const [content, setContent] = useState("");
useEffect(() => {
const getContent = async (url: string) => {
if (!url) return;
const resp = await fetch(url);
const txt = await resp.text();
setContent(txt);
};
getContent(url);
}, [url]);
if (!content) return null;
return <Styled>{content}</Styled>;
}