I've got this error while I was using react-apollo with the graphql API made with nestjs, I have tried first componentWillMount()

Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:You might have mismatching versions of React and the renderer (such as React DOM)You might be breaking the Rules of HooksYou might have more than one copy of React in the same app

So I have fixed like is shown in the code below:


import { useLazyQuery, useMutation } from '@apollo/client'
import React, { useEffect, useState } from 'react'
import {  GET_ALL_PROJECTS } from '../graphql/Queries'
function Home() {
    const [getEmployees, { loading, data, error }] = useLazyQuery(GET_ALL_PROJECTS,
            variables: {}

    if (error) {
    if (data) {
    useEffect(() => {
            }, []);
return (
        <div className="home">...</div>

export default Home

Related Query

More Query from same tag