我正在尝试使用 EditorJS 的编辑器。一切正常,除了当我第一次加载页面时,它会在开始时初始化两个编辑器,并在每次重新加载页面时不断添加新的编辑器。但它们都在<div id='editorjs' />
div 内。有什么我想念的吗?
// react etc. imports
import EditorJS from '@editorjs/editorjs'
const EditorComponent = (props) => {
const [input, setInput] = useState({})
const currentuser = useSelector((state) => state.currentuser)
const editor = new EditorJS({
holderId: 'editorjs',
autofocus: true,
})
const postNews = () => {
// POSTING SUTFF
}
return (
<Grid>
<Grid templateRows='auto min-content' gap={6}>
<div id='editorjs' />
<Button onClick={postNews}>Post news</Button>
</Grid>
</Grid>
)
}
这是来自 dom 的屏幕截图,加载页面后立即添加了两个编辑器。