Files
5chan/src/components/StateLabel.jsx
T

22 lines
582 B
React
Raw Normal View History

2023-06-01 10:43:17 +02:00
import React, { useEffect, useState } from "react";
import { useComment } from "@plebbit/plebbit-react-hooks";
2023-06-01 17:24:44 +02:00
import useStateString from "../hooks/useStateString";
2023-06-01 10:43:17 +02:00
const StateLabel = ({ commentCid, className }) => {
const comment = useComment({commentCid});
2023-06-01 17:24:44 +02:00
const stateString = useStateString(comment);
2023-06-01 10:43:17 +02:00
return (
comment.state === "succeeded" ? null : (
<span className={className}>
<>
<br />
2023-06-01 17:24:44 +02:00
{stateString || comment.state.charAt(0).toUpperCase() + comment.state.slice(1)}
2023-06-01 10:43:17 +02:00
</>
</span>
)
)
};
export default StateLabel;