Skip to content

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

@yanwii

Description

@yanwii

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions