Combination of watch, computed and h creates an infinite loop after building #12105
Unanswered
jcarlosroldan
asked this question in
Help/Questions
Replies: 2 comments 1 reply
-
You should use inject provide to retrieve the form state instead of using useSlots().default()[0] and editing the props manually |
Beta Was this translation helpful? Give feedback.
0 replies
-
IMO, this useage is not correct resulting in problems and I've given you the solution see #8131 (comment) the underlying cause is that the state is
<BuggyForm type="select" name="state" :options="stateOptions"/> here cause the infinite loop because watch(() => [props.value, props.options], () => {
if (props.type === 'select' && !props.options.includes(props.value)) {
emit('update:value', props.options[0]);
}
}); So, the solution is to pass <BuggyForm type="select" name="state" :value="formValue.state" :options="stateOptions"/> |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Vue version
Every version tested 3.2.47 - 3.5.10
Link to minimal reproduction
https://play.vuejs.org/#eNqlWIFu28gR/ZWp2kYyIEvJ5QoUOlmtz3UQHxoniO1rC8norciVtDG5S5BL2YKhf++bWZKiZCdO28CIyd3Z2Zk3M2+GfuycZtlgXerOqDP2Os0S5fVkZonGqzeTC+tzF5eRN86Oh1iQjWxyQX7lyuXKk/F078okprkmrQqjc/KOShvrvPDKxhDUNC+XdG/8igqXaoqc9frBk7OyaezaJWsdYz3NnNXWF6QKutdJ0scBSrQnnDKVKZrGkYv15EOZePPO5el4KO+Dr6yTgTpaYIGiXCv2ZHcTtNL9ykQrsaTwOVwtc1xWUKwXxsKq2OQ68smGlBehGqM+sXcbV1KkLGl4B9dXaq1x21olpeY75cSiTJLWlVjlHRwyNjZrE5eKt9m9ZDAeZhX4P0zOHxSu0sD9hxr3v2vfLajQsBC4M6J8d5Ab0PUKdjfR4KvXRt9Dd6xHjeIs15NXif+pwYnWxykkkpFYfTLrZAids7POq6X/iY8Q7cv7TcZiHMNZh6xK+Y2d/Dc/zzrDFw7aMp3rfHdULXHoiRWy+pKqQicIzk7VUnPi4X3kMo50gbVp94NKdLdP3Xc6rZ5OE6Nt93bWmVnWO2wU832AChhViD/FtE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K0JBZ7GcMNjC7JSfWXkg7BEFcF+cPXlv5zKoNlYIXefTiUp99w/WduW8HP9ZEARTPHxAxK7NWNTZ1tv8BpNZbwg==
Steps to reproduce
Change the country in the last form on the example and it will create an infinite loop. When running vue in debug mode, this won't happen.
What is expected?
To make the Country selector change the City selector.
What is actually happening?
An infinite loop.
System Info
Any additional comments?
Already reported it before: #8131 but after 2 years it was closed with no solution. The closing comment was clearly not a fix, but only contributors can reply now.
Beta Was this translation helpful? Give feedback.
All reactions