'using variables in if/else statetement

I am using props to get an input value with useRef, which value should limit the number of reminders to save by the user. using if statement, I want that the user can save reminders more than the input value obtain with the props in the code below

const maxW = useRef()
const Wmax = maxW.current.value
console.log(Wmax) // value = 8

if (Reminders.length !== Wmax) {
  Reminders.push(Reminder);
  console.log(Reminders);
} else {
  console.log("can not save any more Reminders");
}

when I console log "Wmax" the right value is display in the console as the image below value of Wmax

but unfortunately, the if statement does not read the Wmax value and hence the user can still save more reminders even after reaching the value of Wmax, as shown below exceed

TextReminder.js?1337:59 [{…}]
TextReminder.js?1337:43 8

TextReminder.js?1337:59 (2) [{…}, {…}]
TextReminder.js?1337:43 8
TextReminder.js?1337:59 (3) [{…}, {…}, {…}]
TextReminder.js?1337:43 8
TextReminder.js?1337:59 (4) [{…}, {…}, {…}, {…}]
TextReminder.js?1337:43 8
TextReminder.js?1337:59 (5) [{…}, {…}, {…}, {…}, {…}]
TextReminder.js?1337:43 8
TextReminder.js?1337:59 (6) [{…}, {…}, {…}, {…}, {…}, {…}]
TextReminder.js?1337:43 8
TextReminder.js?1337:59 (7) [{…}, {…}, {…}, {…}, {…}, {…}, {…}

]
TextReminder.js?1337:43 8
TextReminder.js?1337:59 (8) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
TextReminder.js?1337:43 8
TextReminder.js?1337:59 (9) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
TextReminder.js?1337:43 8
TextReminder.js?1337:59 (10) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, 

{…}, {…}]

TextReminder.js?1337:43 8
TextReminder.js?1337:59 (11) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source