Is it possible to sync prop value with writable store and vice versa in Svelte?

is it possible to sync prop value with a writable store value, just like how 2-way binding works. In the example below, I have an accordion where one item can be active at a time. Accordion consists of a Body component where a writable store is used with an initial value from a prop. When the prop changes in the Body component writable store value do not change and when the writable store value changes the prop does not change. The writable store is shared with the Item component with help of setContext. In the Item component, the writable store will change to the id of the current item when the item is clicked on.

Link to repl

Read more here:

Content Attribution

This content was originally published by yousef khalil at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: