react-mentions icon indicating copy to clipboard operation
react-mentions copied to clipboard

Async fetch not working with Apollo Graphql

Open andywong418 opened this issue 3 years ago • 2 comments

Steps to reproduce:

const fetchUsers = (query, callback) => {
  if (!query) return
    getAutocompleteUsers({
	    variables: {
		 username: query,
	    },
    }).then((usersResult) => {
	    callback(usersResult?.data?.getAutocompleteUsers)
    })
  }
  1. Use apollo to fetch a new list of users as shown above to fetch a list of users
  2. Get the list of users and then input as argument to callback function

Expected behaviour: The autocomplete should update according to the fetched results of getAutocompleteUsers

Observed behaviour: No list is displayed when the trigger '@' is typed in, I suspect due to async issues.

Workaround: I have to fetch a static list of users which is not scalable

andywong418 avatar Jan 12 '22 21:01 andywong418

Hello @andywong418, I cannot reproduce your bug. https://codesandbox.io/s/react-mentions-541-j2bym. Can you provide a reproducible example ?

ThibautMarechal avatar Jan 17 '22 13:01 ThibautMarechal

An error occurs when there's a slight time delay https://codesandbox.io/s/react-mentions-541-forked-mj9in (decreasing timeout to 1000 kinda works again) @ThibautMarechal

andywong418 avatar Jan 18 '22 09:01 andywong418