Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/yummy-shrimps-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@threlte/test': patch
---

Use granular state updates on rerender
6 changes: 4 additions & 2 deletions src/lib/props.svelte.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @returns {[Props, (nextProps: Partial<Props>) => void]}
*/
const createProps = (initialProps = {}) => {
let currentProps = $state.raw(initialProps)
let currentProps = $state(initialProps)

const props = new Proxy(/** @type {Props} */ (initialProps), {
get(_, key) {
Expand All @@ -30,7 +30,9 @@ const createProps = (initialProps = {}) => {

/** @param {Partial<Props>} nextProps */
const update = (nextProps) => {
currentProps = { ...currentProps, ...nextProps }
for (const key in nextProps) {
currentProps[key] = nextProps[key]
}
}

return [props, update]
Expand Down
Loading