refactor: conditional props example

This commit is contained in:
HD
2022-06-30 00:04:55 +08:00
parent f1733d030c
commit 435da262bb
3 changed files with 15 additions and 9 deletions
+3 -3
View File
@@ -33,12 +33,12 @@ const Styled = styled.div`
interface Props {
type?: "server" | "channel";
cid?: null | number;
cid?: number;
title?: string;
closeModal: () => void;
}
const InviteModal: FC<Props> = ({ type = "server", cid = null, title = "", closeModal }) => {
const InviteModal: FC<Props> = ({ type = "server", cid, title = "", closeModal }) => {
const { channel, server } = useAppSelector((store) => {
return {
channel: store.channels.byId[cid],
@@ -54,7 +54,7 @@ const InviteModal: FC<Props> = ({ type = "server", cid = null, title = "", close
<CloseIcon className="close" onClick={closeModal} />
</h2>
{!channel?.is_public && <AddMembers cid={cid} closeModal={closeModal} />}
<InviteByEmail cid={channel?.is_public ? null : cid} />
<InviteByEmail cid={channel?.is_public ? undefined : cid} />
</Styled>
</Modal>
);