Skip to content

setFilter old variable - TypeError: Cannot read property '1' of undefined #2250

Answered by jaekunchoi
jaekunchoi asked this question in General
Discussion options

You must be logged in to vote

nevermind, I just had to put default empty array for old variable old = []

Final answer

setFilter((old = []) => { 
  return [val ? parseInt(val, 10) : undefined, old[1]] 
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jaekunchoi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant