jpuri / draftjs-to-html

Library for converting Draftjs editor content state to HTML
MIT License
321 stars 143 forks source link

Outputs empty string with no errors #7

Closed zbrox closed 7 years ago

zbrox commented 7 years ago

When using draftToHtml on a valid raw state I only get an empty string. There are no errors or warning being raised, just an empty string returned.

zbrox commented 7 years ago

This is used in a node.js backend and since I'm not using any ES6 features, I'm also not using babbel or anything of the sort, so I had to import the function like this const draftToHtml = require('draftjs-to-html').default;

zbrox commented 7 years ago

Using babel this seems to be fine.

jpuri commented 7 years ago

Good to know 👍

zbrox commented 7 years ago

Just as an update, it wasn't the ES6 import syntax that was the problem. In my quick test to see if it would work with ES6 I copy pasted the JSON I usually save in a database from DraftJS' convert to raw function. But I didn't paste it as it is but back as JSON so it worked. But where the issue was observed I was actually feeding draftToHtml a string of the JSON :) I was under the wrong impression that draftToHtml was expecting the unparsed JSON string :)