Draftjs mentions browser plugin

I tried to get the mention plugin in js project to work with Browserify. This is due to the fact that our application is built using Browserify.

About this plugin: https://www.draft-js-plugins.com/plugin/mention

In the examples, they use Webpack, and they use import.

I am using require. So, an example of my code:

var React = require('react'), Draft = require('draft-js'), Immutable = require('immutable'), Editor = require('draft-js-plugins-editor'), Mention = require('draft-js-mention-plugin'); var mentionPlugin = Mention.createMentionPlugin(); var MentionSuggestions = mentionPlugin.MentionSuggestions; var plugins = [mentionPlugin]; var Editor = React.createClass({ // Code }); 

I do not use ES6 notation. Does anyone know what I'm doing wrong?

+5
source share
1 answer

This default export for the plugin is the actual create function, so it should be:

 var createMentionPlugin = require('draft-js-mention-plugin'); var mentionPlugin = createMentionPlugin(); var MentionSuggestions = mentionPlugin.MentionSuggestions; var plugins = [mentionPlugin]; 
0
source

Source: https://habr.com/ru/post/1265375/


All Articles