How to pass prop from child component to child component.
Have to pass setScore function as prop from Nav.js to App.js to change the score value. App.js import logo from './logo.svg'; import './App.css'; import Nav from "./Component/nav.js"; function App() { return ( <div className = "App"> <div className = "nav"> <Nav /> </div> <button onClick={setScore(score + 1)}>Increment</button> </div> ); } export default App; ////////////////////////////// Nav.js import {useState} from 'react' import './Style Components/nav.css'; function Nav(){ const [score, setScore] = useState(0); return ( <div className = "nav-container"> <div className="score" id="score"> {score} {console.log(score)} </div> </div> ); } export default Nav;