Uncaught Error: Objects are not valid as a React child (found: Error: Unknown argument “limit” on field “queryNews” of type “Query”.). If you meant to render a collection of children, use an array instead.
type News {
id: ID!
image_src: String!
title: String!
description: String!
resource_link: String!
}
export const GET_NEWS1 = gql`
query QueryNews($offset: Int, $limit: Int) {
queryNews(offset: $offset, limit: $limit) {
description
id
image_src
resource_link
title
}
}
`;
const NewsPage = ({screenWidth}) => {
const { loading, error, data, fetchMore, variables} = useQuery(GET_NEWS1, {
variables: {
offset: 2,
limit: 4,
},
});
console.log(variables)
if (loading) return <p>Loading...</p>;
if (error) return <p>{error}</p>;
return (
<div className={styles.wraper}>
<NavBar/>
<div className={styles.title}>
<NewsTitleW width={(screenWidth > 600)? '518' : '300'}/>
<p className={styles.title_text}>Title</p>
</div>
<Container className=''>
<Row>
{data.queryNews.map(item=>
<CardNews key={item.id} desc={true} news={item} col={6}/>
)}
</Row>
</Container>
</div>
);
};
I don’t understand why it doesn’t see the limit variable?