Draft-js-plugins: Mentions to get data from external API

Created on 18 Oct 2016  路  3Comments  路  Source: draft-js-plugins/draft-js-plugins

Hi!
I have a requirement to provide the Mentions Plugin with data being fetch from and External API. I was trying to implement this based on the Remote Data Mention example you guys have provided and run into an issue which is causing me a headache and I can't figure out for the love of god why it's happening and how to resolve it. I'm happy to provide further info if required. I'm just wondering if you've seen anything like this. This doesn't happen when using the static mention.json file as data source. It's probably something to do with the fact that when the user typing after each char a remove service call is initiated...or something along this line..not sure. Any help would be appreciated.

This is the error I'm getting:
image

and this is roughly how I've implemented the MentionSearch

image

Environment: Visual Studio Code Editor
Typescript and React
For State management I'm using MobX
Getting the data from the external WebAPI I use fetch.

question

All 3 comments

The error in the console suggests that there are two suggestions with the same key. Could you have a look at the web api's response to make sure that there are no duplicates?

Yes, you are correct @Zhouzi , it's my bad, the getMentions method kept pushing the results into the same array hence I got the duplicates. Solution was to clean this array as per below screenshot.
image

Thanks for the help

@GaborLeskoFlach glad you figured it out :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexlatchford picture alexlatchford  路  3Comments

oleksandraab picture oleksandraab  路  3Comments

kaustubh-karkare picture kaustubh-karkare  路  3Comments

dinubs picture dinubs  路  4Comments

paglias picture paglias  路  4Comments