-
-
Save nikolasburk/bc4bbfbac20d724a3ffdeff32cc3747a to your computer and use it in GitHub Desktop.
This file contains 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
const NewPostsSubscription = gql` | |
subscription { | |
Post(filter: { | |
mutation_in: [CREATED] | |
}) { | |
node { | |
id | |
imageUrl | |
description | |
} | |
} | |
}` | |
class ListPage extends React.Component { | |
// ... | |
componentDidMount() { | |
this.subscription = this.props.data.subscribeToMore({ | |
document: NewPostsSubscription, | |
updateQuery: (previousState, {subscriptionData}) => { | |
const newPost = subscriptionData.data.Post.node | |
return { | |
allPosts: [ | |
{...newPost}, | |
...previousState.allPosts | |
] | |
} | |
}, | |
onError: (err) => console.error(err), | |
}) | |
} | |
// ... | |
} |
Hey @AntonBramsen! Sorry this is a typo. It should be this.props.data.subscribeToMore({...})
. Will fix it right away, thanks for the hint!! 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I'm getting a compile error:
error 'newProps' is not defined no-undef
I was wondering where the newProps should be defined?