-
Notifications
You must be signed in to change notification settings - Fork 64
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
useSubscription hook not working properly #43
Comments
The latest news is not rendering server side though if that's what you mean. |
Sorry I think my explanation was vague :) Please check my updated CodeSandbox version again You should see now that it will initially show a "loading" and then it will error out because "data" is undefined Here is the functional component in question: export function LatestNews() {
const { loading, data } = useSubscription(LATEST_NEWS);
return (
<Card className="bg-light">
<CardBody>
<CardTitle>
<h5>Latest News</h5>
</CardTitle>
<CardText>{loading ? "Loading..." : data.latestNews.content}</CardText>
</CardBody>
</Card>
);
} so the useSubscription hook is creating you can see this in a slightly modified version of my CodeSandbox which just Here you should see in the console: useSubscription is: { loading: true,
error: undefined,
data: undefined,
variables: undefined } essentially, the problem seems to be that useSubscription returns |
ignore the above! i realized that i forgot add a websocket link so of course it wouldn't work :) however, there is nothing in the next-apollo docs about subscriptions - are they supported? if so, what would the setup look like? |
Hey Adam,
I'm trying to port over the @apollo/react-hooks demo from React to Next.js using your library and came across this..
Here is my CodeSandbox.
useQuery
anduseMutation
seem to be working perfectly, butuseSubscription
will return the value of "data" as undefined (althought "loading" seems to be correct)Any idea what might be the cause of this?
The text was updated successfully, but these errors were encountered: