Last active
August 28, 2019 10:03
-
-
Save kettanaito/d510a6c8aa3ed30b045f700639026571 to your computer and use it in GitHub Desktop.
Redux action after GraphQL query (Apollo)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { connect } from 'react-redux' | |
import { useQuery } from '@apollo/react-hooks' | |
import reduxAction from './path/to/redux/action' | |
const MY_QUERY = gql` | |
... | |
` | |
const Component = () => { | |
const { data, loading, error } = useQuery(MY_QUERY, { | |
onCompleted: (data) => { | |
reduxAction(data) | |
} | |
}) | |
return null | |
} | |
export default connect( | |
null, | |
{ | |
reduxAction | |
} | |
)(Component) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment