Draft-js: Uncaught TypeError: contentState.createEntity is not a function

Created on 8 Oct 2016  Â·  5Comments  Â·  Source: facebook/draft-js

How to create media Entity。I learn from examples, but createEntity not exist in My test。

All 5 comments

yup , it seems that that create entity from state is on master branch only. and is not released yet. documentation is not clear on that.

you can use something like this for now:

    entityKey = Entity.create('atomic', 'IMMUTABLE', {src: "foo bar"})
    @.props.onChange(AtomicBlockUtils.insertAtomicBlock(
        @.props.editorState,
        entityKey,
        ' '
      )); 

example in coffeescript (sorry)

Closing as this was a question that was answered (thanks for answering @michelson !) This will be out with the next release, my apologies for having inaccurate documentation. we'll try to get something out sooner than later

I think the main confusion is that the documentation says to use Entity.create and has links to supporting examples that use "createEntity". So there's effectively no complete example on how to use Entity.create.

You can still see the old version here.
Same for the "link" example, older version works on latest release.

I know this is an alpha release but people are already using it in production so rc branches might reduce the number of issues like this one I think.

i use 0.10 still see this error 6 how to fix this?

Was this page helpful?
0 / 5 - 0 ratings