Feb 27, 2023
"Lifting state up" works:
https://beta.reactjs.org/learn/sharing-state-between-components
Define the state in the calling function:
Declare in Body.tsx
const [debugMessage, setdebugMessage] = useState("123");
pass the state and the function to change it
<Debug_user start={1} initmessage="hello" setDebugMesssage={setDebugMesssage} />
<Debug start={1} initmessage="hello" setDebugMesssage={setDebugMesssage} debugMessage={debugMessage} />
and the element (div, textarea, etc.) will change in the called function!
Debug.tsx:
return (
<div >
{debugMessage}