[Vuejs]-Object.assign breaks v-for (functional component)

0👍

Quick answer:

Object.assign will change the first parameter (=target object). This caused my settingsObj to take on the other settings every time, until it had the settings of the last instance.

Easily resolved by changing

Object.assign(props.settingsObj, {setting: val, })

into

Object.assign({}, props.settingsObj, {setting: val, })

Sorry for blaming Vue, all my fault. Not exactly sure why this only happens with functional components, but it must be related to normal components being isolated in their own Vue instance.

Leave a comment