refactor: PropsWithChildren

This commit is contained in:
Tristan Yang
2022-08-29 10:33:53 +08:00
parent d57072f2be
commit d40afe1500
3 changed files with 8 additions and 17 deletions
+2 -3
View File
@@ -1,13 +1,12 @@
import { FC, ReactNode, useEffect, useState } from "react";
import { FC, useEffect, useState, PropsWithChildren } from "react";
import { createPortal } from "react-dom";
interface Props {
id?: string;
mask?: boolean;
children?: ReactNode;
}
const Modal: FC<Props> = ({ id = "root-modal", mask = true, children }) => {
const Modal: FC<PropsWithChildren<Props>> = ({ id = "root-modal", mask = true, children }) => {
const [wrapper, setWrapper] = useState<HTMLDivElement | null>(null);
useEffect(() => {
@@ -1,4 +1,4 @@
import { FC, ReactNode } from "react";
import { FC, PropsWithChildren, ReactNode } from "react";
import styled from "styled-components";
import { useLocation, NavLink } from "react-router-dom";
import backIcon from "../../assets/icons/arrow.left.svg?url";
@@ -102,10 +102,9 @@ interface Props {
navs: Nav[];
dangers: [Danger | boolean];
nav: { title: string; name?: string; component?: ReactNode };
children: ReactNode;
}
const StyledSettingContainer: FC<Props> = ({
const StyledSettingContainer: FC<PropsWithChildren<Props>> = ({
closeModal,
title = "Settings",
navs = [],
+4 -11
View File
@@ -1,7 +1,7 @@
// import React from 'react'
import Tippy, { TippyProps } from "@tippyjs/react";
import styled from "styled-components";
import { FC, ReactElement } from "react";
import { FC } from "react";
const StyledTip = styled.div`
position: relative;
@@ -39,18 +39,11 @@ const StyledTip = styled.div`
}
`;
interface IProps extends TippyProps {
type Props = {
tip: string;
children: ReactElement;
}
} & TippyProps;
const Tooltip: FC<IProps> = ({
tip = "",
placement = "right",
delay = null,
children,
...rest
}) => {
const Tooltip: FC<Props> = ({ tip = "", placement = "right", delay = null, children, ...rest }) => {
const defaultDuration: [number, number] = [300, 250];
return (