CommentEditorLazyRenderer.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import React from 'react';
  2. import dynamic from 'next/dynamic';
  3. import { RendererOptions } from '~/services/renderer/renderer';
  4. import { useSWRxPageComment } from '../../stores/comment';
  5. import { Skelton } from '../Skelton';
  6. import { CommentEditorProps } from './CommentEditor';
  7. import CommentEditorStyles from './CommentEditor.module.scss';
  8. const CommentEditor = dynamic<CommentEditorProps>(() => import('./CommentEditor').then(mod => mod.CommentEditor),
  9. {
  10. ssr: false,
  11. loading: () => <div className={`${CommentEditorStyles['comment-editor-styles']} form page-comment-form`}>
  12. <div className='comment-form'>
  13. <div className='comment-form-user'>
  14. <Skelton additionalClass='rounded-circle picture' roundedPill />
  15. </div>
  16. <Skelton additionalClass="page-comment-commenteditorlazyrenderer-body-skelton grw-skelton" />
  17. </div>
  18. </div>,
  19. });
  20. type Props = {
  21. pageId?: string,
  22. rendererOptions: RendererOptions,
  23. }
  24. export const CommentEditorLazyRenderer = (props: Props): JSX.Element => {
  25. const { pageId, rendererOptions } = props;
  26. const { mutate } = useSWRxPageComment(pageId);
  27. return (
  28. <CommentEditor
  29. rendererOptions={rendererOptions}
  30. isForNewComment
  31. replyTo={undefined}
  32. onCommentButtonClicked={mutate}
  33. />
  34. );
  35. };