Skip to content

How should I proceed to recursively target a store key/value? #2276

Discussion options

You must be logged in to vote

Shortest suspense ever, I managed to make it by refactoring my code:

updateForm({ key, value, type, level = null, store = null  }) {
     level = level ?? [this[type].form[key]]
     store = store ?? this[type].form
     console.log(`updateForm 
     key: ${key}
     value: ${value} 
     type: ${type} 
     level: ${level}`)
     if (level.length === 1) {
       //guard against undef keys
       if (store[level[0]] === undefined) store[level[0]] = "" // TODO make sure it works with othjer primitive types
       store[key] = value
     }
    

     if (level.length > 1) {
       const isArray = typeof level[0] === "number"
       //guard against undef keys
       if (store[level[0]] === u…

Replies: 1 comment

Comment options

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