MENU
Importing JQuery
To install JQuery:
npm install jquery |
In general, you should try to access the DOM nodes after the initial render. (such as in the componentDidMount method if you are using the class syntax.)
RESETRUNFULL
import $ from 'jquery';import {useState, useEffect} from 'react';function App() {
const [n, setN] = useState(0);
useEffect(()=>{
$("button").on('click', ()=>{
setN(n=>(n+1));
})
},[])
return (
<button>{n}</button>
);}export default App;