adamsoffer / adamsoffer/next-apollo
Detected multiple renderers concurrently rendering the same context provider
- Ngôn ngữ chính
- TypeScript
- Star
- 477
- Fork
- 62
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
I get the following warning when using this as hoc inside my Next.js app
My Apollo client:
```
import { ApolloClient, InMemoryCache } from '@apollo/client';
import { NextPageContext } from 'next';
import { withApollo } from 'next-apollo';
import { PaginatedPosts } from '../generated/graphql';
const createClient = (ctx: NextPageContext) =>
new ApolloClient({
uri: 'http://localhost:4000/graphql',
headers: {
cookie: (typeof window === 'undefined' && ctx?.req?.headers.cookie) || '',
},
cache: new InMemoryCache({
typePolicies: {
Query: {
fields: {
posts: {
keyArgs: [],
merge(existing: PaginatedPosts | undefined, incoming: PaginatedPosts): PaginatedPosts {
return {
...incoming,
posts: [...(existing?.posts || []), ...incoming.posts],
};
},
},
},
},
},
}),
credentials: 'include',
});
export default withApollo(createClient);
```
and this is how I am using it inside my pages
```
import { Box, Button, Flex, Heading, Link } from '@chakra-ui/react';
import { NextPage } from 'next';
import NextLink from 'next/link';
import { useRouter } from 'next/router';
import IndexHeader from '../components/IndexHeader';
import Layout from '../components/Layout';
import PostStack from '../components/PostStack';
import { PaginatedPosts, usePostsQuery } from '../generated/graphql';
import withApollo from '../utils/withApollo';
const Index: NextPage = () => {
const router = useRouter();
const { data, loading, fetchMore, variables } = usePostsQuery({
variables: {
limit: 15,
cursor: null,
},
notifyOnNetworkStatusChange: true,
});
const fetchMoreVar = () => ({
variables: {
limit: variables?.limit,
cursor: data?.posts.posts[data?.posts.posts.length - 1]?.createdAt,
},
});
return (
);
};
export default withApollo({ ssr: true })(Index);
```
on rendering this my console spits out the following warning
```
Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.
```
This warning only shows up in the pages in which ssr is set to true
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.