re-editor
re-editor copied to clipboard
REACT HOOKS下从后端获取文本后没办法渲染?
异步从后端获取文本后不能够成功渲染,文本框始终是空的
export const Editor = () => {
const [value, setValue] = useState(null);
useEffect(() => {
httpRequest("get", api.NoticeManage).then(response=>{
setValue(JSON.parse(response.data.text))
})
}, [])
const handleChange = (value) => {
setValue(JSON.stringify(value.toJS()))
}
return (
<ReEditor
value={value}
onChange={handleChange}
placeholder="请输入内容"
// onImageUpload={this.handleImageUpload}
/>
)
}