Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$merge deletes properties that are undefined #12

Open
ngryman opened this issue Apr 11, 2018 · 0 comments
Open

$merge deletes properties that are undefined #12

ngryman opened this issue Apr 11, 2018 · 0 comments

Comments

@ngryman
Copy link

ngryman commented Apr 11, 2018

Hey Justin,

This code gives me an unexpected output:

const initialState = {
  paymentInfo: {
    cardNumber: '',
    cardExpiry: ''
  }
}

const paymentInfo = {
  cardNumber: undefined,
  cardExpiry: '12/22'
}

const nextState = update(['paymentInfo', $merge(paymentInfo)], state);

Current value of nextState:

{
  paymentInfo: {
    cardExpiry: '12/22'
  }
}

Expected value of nextState:

{
  paymentInfo: {
    cardNumber: '',
    cardExpiry: '12/22'
  }
}

I think that somehow the fact that that cardNumber is undefined makes qim discarding it entirely when cloning the object. I didn't dive deeper though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant