If you're running the same page in two different browser tabs, these are completely unrelated. Each has its own memory, and executes its own javascript, and one cannot affect the other, unless you involve a server or websockets.
Your current code works fine, as long as you stay in the same tab. Your state is in the App component and will be available to both the adults route and the child route. To test this, try adding a link from your adult page to your children page. You can increment a few times on the adult page, then link to the children page and see the same value
import React from "react";
import { Link } from "react-router-dom";
const Adult = (props) => {
return (
<div>
<button onClick={props.incAdult}>Increment</button>
<p> No of Adults : {props.adults} </p>
<Link to="/children">Test</Link>
</div>
);
};
export default Adult;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…