Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binding_property_non_reactive warning is more than annoying actually causes problems migrating #14295

Closed
go-aegian opened this issue Nov 13, 2024 · 2 comments

Comments

@go-aegian
Copy link

Describe the bug

having a variable declared as $state which is an object with properties that have no $state in their definition causes this warning

class Address {
    street?: string
}

let address: Address = $state();

<TextInput bind:value={address.street} 

These cause this warning and no value can be typed

client.js:2682 [svelte] binding_property_non_reactive
bind:value={address.street} (src/lib/editor.svelte) is binding to a non-reactive property

Is there a way if the object variable is declared reactive $state allow all its properties despite not being declared reactive to behave like their are reactive?

Or how would this can be solved, in cases where the class definition is an external generated and no way of modifying to make it reactive and not having to redefine classes and manually copy them?

Reproduction

no need to repro just an example of the problem

Logs

No response

System Info

svelte 5 ---

Severity

blocking an upgrade

Additional Information

No response

@eltigerchino eltigerchino transferred this issue from sveltejs/kit Nov 14, 2024
@dm-de
Copy link

dm-de commented Nov 14, 2024

You need to do this:
let address: Address = $state({});

Then you will probably discover this issue, if you use default value with $bindable:
#14254

@dummdidumm
Copy link
Member

Closing as duplicate of #10560 - #10560 (comment) specifically has a workaround that should help you when you can't modify the classes

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants