I have a functional component where there is a timer running and the timer updates
var [time, setTime] = useState(180000);
( i didn't show the code for the timer as i don't believe it's needed to answer my question)
this is found in countDownTimer.js as seen below
function CountDownTimer(props) {
var [time, setTime] = useState(180000);
}
Then in another tab I have the function
updateGame() {
}
is there any way to get the value stored in
var [time, setTime] = useState(180000);
into the updateGame() function
I want to achieve something like this
function CountDownTimer(props) {
[time, setTime] = useState(100);
export const GetTime = () => {
const time = time
return time
}
}
import {getTime} from "./countDownTimer.js"
updateGame() {
const time = getTime()
console.log(time)
//prints 100
}
silly attempt at it but hopefully you get the point.