convertFromRaw giving this error "Invariant Violation: invalid RawDraftContentState"

Viewed 1981

I want to convert html code to draft object to save my editorState But convertFromRaw function giving me Invariant Violation: invalid RawDraftContentState <- this error.

try {
  const htmlToDraftObject = htmlToDraft(
post.content
  );
  console.log(htmlToDraftObject);
  console.log(convertFromRaw(htmlToDraftObject));
} catch (error) {
  console.log(error, "error");
}

console.log(htmlToDraftObject);

this line is returns this object

{"contentBlocks":[{"key":"apdo3","type":"unstyled","text":"\"\\n","characterList":[{"style":[],"entity":null},{"style":[],"entity":null},{"style":[],"entity":null}],"depth":0,"data":{}},{"key":"2lgc","type":"unstyled","text":"","characterList":[],"depth":0,"data":{}},{"key":"118p1","type":"atomic","text":" \\n","characterList":[{"style":[],"entity":"5526de6f-06fd-445d-9ae4-e5bae145adab"},{"style":[],"entity":null},{"style":[],"entity":null}],"depth":0,"data":{}},{"key":"13tke","type":"unstyled","text":"\\n\"","characterList":[{"style":[],"entity":null},{"style":[],"entity":null},{"style":[],"entity":null}],"depth":0,"data":{}}],"entityMap":{"5526de6f-06fd-445d-9ae4-e5bae145adab":{"type":"IMAGE","mutability":"MUTABLE","data":{"src":"\\\"https://p.bigstockphoto.com/GeFvQkBbSLaMdpKXF1Zv_bigstock-Aerial-View-Of-Blue-Lakes-And--227291596.jpg\\\"","alt":"\\\"undefined\\\"","height":"","width":""}}}}

post.content is a simple html code

I tried it without htmlToDraft function too .But it gave me another error

what am I doing wrong?

0 Answers
Related