-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
currently, if I have
const state = {}
and I attempt to update the state with devices like so,
const id = '123'
dotProp.set(state, 'devices', list => [...list, id])
I will get an error because list is being defaulted to an object. Instead it would be nice to leave that as undefined for the user to be able to use default params to have better control. So instead it would look like this,
const id = '123'
dotProp.set(state, 'devices', (list = []) => [...list, id])
or if I want my devices to be an object keyed on the ids I could do something like,
const device = {id:'123'}
dotProp.set(state, 'devices', (devices = {}) => {...devices, device})
An alternative approach would be to have a optional parameter at the end to change the default value from {} to []
karlguillotte and LinusUhilleer
Metadata
Metadata
Assignees
Labels
No labels