mirror of https://github.com/sveltejs/svelte
fix: don't set state withing `with_parent` in proxy (#16176)
Closes #16164 We can't set everywhere within with_parent otherwise if it's the first time we are reading a derived it could look like we are setting state in a derived (which you are not).elliott/13891
parent
931f211b25
commit
7e588857c2
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: don't set state withing `with_parent` in proxy
|
@ -0,0 +1,5 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
async test() {}
|
||||||
|
});
|
@ -0,0 +1,15 @@
|
|||||||
|
<script>
|
||||||
|
function with_writes(initialState) {
|
||||||
|
const derive = $state(initialState)
|
||||||
|
return derive
|
||||||
|
}
|
||||||
|
|
||||||
|
let data = $state({ example: 'Example' })
|
||||||
|
let my_derived = $derived(with_writes({ example: data.example }))
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
my_derived.example = 'Bar'
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<input bind:value={data.example} />
|
Loading…
Reference in new issue