score:0

type ComponentProps = {
  id: number;
}

const Component = ({ id }: ComponentProps) => {
  const { data, loading, error } = useDataAboutThing({
    variables: {
       id: id,
    },
  });

  const [event, setEvent] = React.useState([]);

  if (loading) return <div>Loading...</div>;

  if (error) return <div>Error!</div>;

  React.useEffect(() => {
    if(data.information) setEvent(dataInformation)
  }, [data]) // Error: Rendered more hooks than during the previous render.

  return (
    ...
  );

score:0

type ComponentProps = {
  id: number;
}

const Component = ({ id }: ComponentProps) => {
  const { data, loading, error } = useDataAboutThing({
    variables: {
       id: id,
    },
  });

  const [event, setEvent] = React.useState([]);

      React.useEffect(() => {
       if (data?.information) {
          setEvent(data.information)
       }
      }, [data]);

  if (loading) return <div>Loading...</div>;

  if (error) return <div>Error!</div>;

  return (
    ...
  );

Related Query

More Query from same tag