Got it.
React doesn't care about the value of un, only the states of certain variables. Fixed it by using useState().
un
useState()