HubSpot/draft-convert

Cannot read property 'getCurrentContent' of undefined

Closed this issue · 2 comments

Hi Drafters :)

Basicly, I'm trying to use draft-convert to render my EditorState content.

Here my code :

`const DisplayEditor = (props) => {

const currentContent = props.oldInput.getCurrentContent();
const html = convertToHTML(currentContent);
return html;

};`

That's a stateless component that get the EditorState from the oldInput props, and I'm sure that I got something from there.

But I got this error in the console : Cannot read property 'getCurrentContent' of undefined.

If you got a hint :)

Thanks,

I think there's some confusion on what draft-convert's purpose is here. If you have an EditorState you want to render in React, you should render it with the regular draft-js Editor component passing it in as a prop instead of converting to HTML then returning that.

I think that exception sounds like an issue with the code in your example where oldInput isn't defined, since draft-convert doesn't ever call getCurrentContent.

Thanks :)