我正在使用 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) 我正在为我的应用程序创建上下文,并且出现此打字稿错误“类型‘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)