Yuki Takei 4 лет назад
Родитель
Сommit
96ec5a53b9

+ 1 - 5
packages/app/src/components/PageComment.tsx

@@ -5,7 +5,7 @@ import React, {
 import { Button } from 'reactstrap';
 
 import CommentEditor from './PageComment/CommentEditor';
-import CommentAny from './PageComment/Comment';
+import Comment from './PageComment/Comment';
 import ReplayComments from './PageComment/ReplayComments';
 import DeleteCommentModal from './PageComment/DeleteCommentModal';
 
@@ -16,10 +16,6 @@ import { useSWRxPageComment } from '../stores/comment';
 
 import { ICommentHasId, ICommentHasIdList } from '../interfaces/comment';
 
-// todo: Comment component will be updated to typescript
-// the below any is workaround to avoid WithTranslation IntrinsicAttributes & Omit error
-const Comment = CommentAny as any;
-
 type Props = {
   appContainer: AppContainer,
   pageId: string,

+ 12 - 7
packages/app/src/components/PageComment/Comment.jsx

@@ -1,7 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
 
-import { withTranslation } from 'react-i18next';
+import { useTranslation } from 'react-i18next';
 import { format } from 'date-fns';
 
 import { UncontrolledTooltip } from 'reactstrap';
@@ -226,11 +226,6 @@ class Comment extends React.PureComponent {
 
 }
 
-/**
- * Wrapper component for using unstated
- */
-const CommentWrapper = withUnstatedContainers(Comment, [AppContainer, PageContainer]);
-
 Comment.propTypes = {
   t: PropTypes.func.isRequired, // i18next
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
@@ -243,4 +238,14 @@ Comment.propTypes = {
   onComment: PropTypes.func,
 };
 
-export default withTranslation()(CommentWrapper);
+const CommentWrapperFC = (props) => {
+  const { t } = useTranslatiion();
+  return <Comment t={t} {...props} />
+}
+
+/**
+ * Wrapper component for using unstated
+ */
+ const CommentWrapper = withUnstatedContainers(CommentWrapperFC, [AppContainer, PageContainer]);
+
+export default CommentWrapper;