小编YCr*_*his的帖子

React-markdown 不渲染 Markdown

我正在使用 React-markdown 来呈现输入的值。问题是归约没有得到应有的处理,例如如果我使用这个表达式“#hello world”,文本应该显示为h1中的文本,但它正常显示,其他表达式也无法显示被执行。

//setDataForm coming from parent 
//const [dataForm, setDataForm] = useState()

const NoteForm = ({setDataForm})=> {
   const handleChange = (e) => {
        const { name, value } = e.target
        setDataForm({
            ...dataForm,
            [name]: value
        })
   }

   <textarea
     placeholder="Description"
     onChange={handleChange}
     name="description"
   ></textarea>

   <ReactMarkdown
     className="w-full h-[100vh] outline-none"
     children={dataForm?.description}
     remarkPlugins={[remarkGfm]}
     escapeHtml={false}
   />
}
Run Code Online (Sandbox Code Playgroud)

reactjs react-markdown

5
推荐指数
1
解决办法
5927
查看次数

类型“Dispatch&lt;any&gt;”不可分配给类型“() =&gt; null”.ts(2322)

我正在为我的应用程序创建上下文,并且出现此打字稿错误“类型‘Dispatch’不可分配给类型‘() => null’.ts(2322)’”,我是打字稿的新事物,我不明白错误。

这是我的代码:

import { createContext, useEffect, useReducer } from "react";

const INITIAL_STATE = {
  user: JSON.parse(localStorage.getItem('user') || '{}'),
  loading: false,
  error: null,
  dispatch: ()=>null
};

export const AuthContext = createContext(INITIAL_STATE);

const AuthReducer = (state:any, action:any) => {
  switch (action.type) {
    case "LOGIN_START":
      return {
        user: null,
        loading: true,
        error: false,
      };
    case "LOGIN_SUCCESS":
      return {
        user: action.payload,
        loading: false,
        error: false,
      };
    case "LOGIN_FAILURE":
      return {
        user: null,
        loading: false,
        error: action.playload,
      };
    case "LOGOUT":
      return {
        user: …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs

3
推荐指数
1
解决办法
3772
查看次数

标签 统计

reactjs ×2

react-markdown ×1

typescript ×1