Skip to content

TypeError: Object(...) is not a function #820

@jscastanos

Description

@jscastanos

Actual Behavior
Throws error when using useQuery.

Expected Behavior
Will fetch the data properly.

Here's a very simple implementation

Users.jsx

import React from "react";
import { useQuery } from "react-query";

const fetchUsers = async () => {
  const response = await fetch("https://jsonplaceholder.typicode.com/users");
  return response.json();
};

const Users = () => {
  const { data, status } = useQuery("products", fetchUsers);
  console.log(data);

  return (
    <React.Fragment>
      <ul>
        <li>{/* list of users */}</li>
      </ul>
    </React.Fragment>
  );
};

export default Users;

package.json

"react": "^16.0.0",
"react-query": "^2.5.6",

Environment
Node Version : v14.2.0

Browser
Microsoft Edge: v84.0.522.50

Screenshot Result
1

I followed a video tutorial but I wonder why it gives me an error when it's just a simple implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions