Having such a simple React
App:
import React, { useState, useEffect, useRef } from "react";
import ReactDOM from 'react-dom'
function App() {
const [inputValue, setInputValue] = useState("");
const count = useRef(0);
useEffect(() => {
count.current = count.current 1;
});
return (
<>
<input
type="text"
//value={inputValue}
//onChange={(e) => setInputValue(e.target.value)}
/>
<h1>Render Count: {count.current}</h1>
</>
);
}
const rootElement = document.getElementById('root') ReactDOM.render(, rootElement)
I'm getting en errors:
(0 , _react.useState) is not a function (0 , _react.useRef) is not a function
What Am I doing wrong?
CodePudding user response:
React hooks are introduced in 16.8 version. So you can't use useState
, useEffect
and any hooks in <16.8 version on react.