Hemadri Dasari
Hemadri Dasari

Reputation: 34014

React V16.7 TypeError: Object(...) is not a function

  import React, { useContext } from 'react';
  useContext is undefined.

error details:

  Uncaught (in promise) TypeError: Object(...) is not a function

error when processing

   const context = useContext(UserContext);

Current react versions:

   "react": "^16.7",
  "react-dom": "^16.7",

Upvotes: 2

Views: 2508

Answers (1)

Hemadri Dasari
Hemadri Dasari

Reputation: 34014

To fix the issue downgrade react and react-dom to 16.7.0-alpha.2 as hooks are not available in v16.7

    "react": "16.7.0-alpha.2",
    "react-dom": "16.7.0-alpha.2"

Upvotes: 5

Related Questions