I copied the example of the draft.js editor and run it. This is an example from the official repository. https://github.com/facebook/draft-js/blob/master/examples/draft-0-10-0/link/link.html But when you click on the button
<button onMouseDown={this.confirmLink}> Confirm</button>
The function _confirmLink
fails:
Uncaught TypeError: contentState.createEntity is not a function
_confirmLink(e) {
e.preventDefault();
const {editorState, urlValue} = this.state;
const contentState = editorState.getCurrentContent();
console.log('contentState->', contentState)
const contentStateWithEntity = contentState.createEntity('LINK', 'MUTABLE', {url: urlValue});
Draft.js can not create an entity. console.log('contentState->', contentState) outputs to the console:
What could be the problem in this case?