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

Mahmudul Haque picture Mahmudul Haque · Nov 1, 2018 · Viewed 10.8k times · Source

I'm learning React from this channel. Recently, I stumbled upon React Hooks from here. So, I tried to convert a class based component to hook based. Here is my class based component:

Here is my converted component: https://codesandbox.io/s/n0lw4wo550?module=%2Fsrc%2FAddNinja.js

But I'm getting following error:

enter image description here

Answer

Murli Prajapati picture Murli Prajapati · Nov 1, 2018

React hooks are available in React v16.8.0. updated your react and react dom version to 16.8.0.

"react": "16.8.0",
"react-dom": "16.8.0",  

Here is your code with updated verion:https://codesandbox.io/s/qq90900xr4