Search code examples
draftjs

How to retrieve and display Draft-js raw object in a react component?


Although the author of Draft-js said that he "didn't want to release any conversion utilities" (https://github.com/facebook/draft-js/issues/62),

I still want to ask that after saving raw object into database, how can we conveniently retrieve and display the raw object in our react component?

And how can we customized the display effect, to be different with effect of displaying it using Draft-js Editor component with the readOnly prop? Because we often want to customize the display effect, for the display effect is always different with the effect when we were editing in the editor.


Solution

  • We will be facing this issue shortly. It's been our plan to simply provide a different blockRendererFn and possibly a different blockStyleFn to the Editor when rendering on front of the site (in readOnly=true mode). That way the bits of UI needed for authoring the custom content blocks will not exist.