re-editor icon indicating copy to clipboard operation
re-editor copied to clipboard

REACT HOOKS下从后端获取文本后没办法渲染?

Open yanwii opened this issue 4 years ago • 0 comments

异步从后端获取文本后不能够成功渲染,文本框始终是空的

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}
        />
    )
}

yanwii avatar May 06 '21 09:05 yanwii