refactor: add typescript definition and fix some type error

This commit is contained in:
HD
2022-06-23 22:58:13 +08:00
parent b66919114d
commit e0bbbf4f30
39 changed files with 640 additions and 324 deletions
@@ -1,4 +1,4 @@
import { useState, useEffect } from "react";
import { useState, useEffect, FC } from "react";
import styled from "styled-components";
const Styled = styled.div`
@@ -12,7 +12,11 @@ const Styled = styled.div`
color: #eee;
`;
export default function Code({ url = "" }) {
interface Props {
url: string;
}
const Code: FC<Props> = ({ url }) => {
const [content, setContent] = useState("");
useEffect(() => {
const getContent = async (url: string) => {
@@ -26,4 +30,6 @@ export default function Code({ url = "" }) {
if (!content) return null;
return <Styled>{content}</Styled>;
}
};
export default Code;