-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for returning a promise from a data
provider function
#314
Comments
We currently don't support promises as return values but only good old callbacks. You can make it work by appending It would be nice to enhance react-mentions adding support for returning promises, though. :) |
data
provider function
Hm. I tried that as well - }` The issue still persists (the above is identical to the example other than using axios instead of fetch, which should be inconsequential). |
Your example still does not call the callback (second arg provided to your function). Change your code to:
|
Wow. Yes. When I changed it away from the promise I forgot to add in the callback. Apologies and many thanks for the quick response! Thank you. :) |
Also - is there any way to grab the values of the object in the array that is selected from the dropdown? I see onAdd but it seems like it only passes back the "id" back, and I need to grab several values. |
Steps to reproduce:
<MentionsInput singlieLine={false} value={description.value} onChange ={this.handleChangeStoryDescription}> <Mention trigger="@" data={ this.fetchUsers } /> </MentionsInput>
fetchUsers = (query)=> { let users; console.log(query) if (!query) return axios.get(getUsers(query)).then( ({ data }) => { users = data.data.map((e, idx)=>{ let obj = { id: e._id, display: e.firstName + " " + e.lastName, } return obj }) return users // users is an array of objects formatted as per above }) .catch( ( error ) => { console.log( error ); }).then(function (users) { console.log(users) return users }); }
The text was updated successfully, but these errors were encountered: