Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MarkdownEditor Backtick Error #195

Open
jongjin1010 opened this issue Nov 6, 2022 · 1 comment
Open

MarkdownEditor Backtick Error #195

jongjin1010 opened this issue Nov 6, 2022 · 1 comment

Comments

@jongjin1010
Copy link

import MarkdownEditor from "@uiw/react-markdown-editor";
import { contentAtom } from "atoms/AtomContainer";
import React, { useState } from "react";
import { useRecoilState } from "recoil";
import * as S from "./style";

interface Props extends React.HTMLAttributes<HTMLDivElement> {
  isContentNull: boolean;
}

function WriteContent({ isContentNull }: Props) {
  const [activeIndex, setActiveIndex] = useState<number>(0);
  const [content, setContent] = useRecoilState(contentAtom);

  const tabClickHandler = (index: number) => {
    setActiveIndex(index);
  };

  const tabbar = [
    {
      tabTitle: (
        <S.Tabs
          key="write-part"
          className={activeIndex === 0 ? "is-active" : ""}
          onClick={() => tabClickHandler(0)}
        >
          글작성
        </S.Tabs>
      ),
      tabContent: (
        <MarkdownEditor
          visible={false}
          hideToolbar={false}
          onChange={setContent}
          theme="dark"
          value={content}
        />
      ),
    },
    {
      tabTitle: (
        <S.Tabs
          key="preview-part"
          className={activeIndex === 1 ? "is-active" : ""}
          onClick={() => tabClickHandler(1)}
        >
          미리보기
        </S.Tabs>
      ),
      tabContent: <MarkdownEditor.Markdown source={content} />,
    },
  ];

  return (
    <S.ContentBox isNull={isContentNull}>
      <S.Tabbar>
        {tabbar.map((idx) => {
          return idx.tabTitle;
        })}
      </S.Tabbar>
      <S.Markdown>{tabbar[activeIndex].tabContent}</S.Markdown>
    </S.ContentBox>
  );
}

export default WriteContent;

In the above code, If you type a backtick(`) three times in the MarkdownEditor, the following error occurs:

Warning: Expected `onClick` listener to be a function, instead got a value of `string` type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants