I am unable to run this React code snippet using repl.it.
Can you please guide me where I am going wrong.
I am unable to run this React code snippet using repl.it.
Can you please guide me where I am going wrong.
Any JavaScript files that contain React templates need to use the .jsx
file extension, and then need to import React.
App.jsx
import React from 'react';
import { 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>
</>
);
}
export default App;