Skip to content

Instantly share code, notes, and snippets.

@david-arteaga
Last active August 28, 2019 15:48
Show Gist options
  • Save david-arteaga/1fd9b00d79cefddb0e99f3af63cf3897 to your computer and use it in GitHub Desktop.
Save david-arteaga/1fd9b00d79cefddb0e99f3af63cf3897 to your computer and use it in GitHub Desktop.
[JSON cannot serialize cyclic structures error] #react-native #graphql #error #refetch

This error usually happens when you use the refetch function in a TouchableOpacity like this: <TouchableOpacity onPress={refetch} ... />.

The error happens because the onPress attribute of TouchableOpacity gets passed in a param, that graphql tries to use as variables but can't, since it is a cyclic structure.

Fix it by doing the following: <TouchableOpacity onPress={() => refetch()} ... />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment