diff --git a/.changeset/yummy-shrimps-deny.md b/.changeset/yummy-shrimps-deny.md new file mode 100644 index 0000000..e321f95 --- /dev/null +++ b/.changeset/yummy-shrimps-deny.md @@ -0,0 +1,5 @@ +--- +'@threlte/test': patch +--- + +Use granular state updates on rerender diff --git a/src/lib/props.svelte.js b/src/lib/props.svelte.js index 64c94a4..455613e 100644 --- a/src/lib/props.svelte.js +++ b/src/lib/props.svelte.js @@ -10,7 +10,7 @@ * @returns {[Props, (nextProps: Partial) => void]} */ const createProps = (initialProps = {}) => { - let currentProps = $state.raw(initialProps) + let currentProps = $state(initialProps) const props = new Proxy(/** @type {Props} */ (initialProps), { get(_, key) { @@ -30,7 +30,9 @@ const createProps = (initialProps = {}) => { /** @param {Partial} nextProps */ const update = (nextProps) => { - currentProps = { ...currentProps, ...nextProps } + for (const key in nextProps) { + currentProps[key] = nextProps[key] + } } return [props, update]