Replies: 3 comments 5 replies
-
Both are valid approaches. It is possible to combine the value and the updater into a single context like this: https://lit.dev/playground/#sample=examples%2Fcontext-basics&gist=5aa7d41fe7a1f3132601a9363e70879d I'd prefer this over having to manage a separate context just for the updater. But using events is also quite idiomatic for web components so using it to update the value seems fine. Depending on how other providers are configured, you may want to stop propagation of the event so it doesn't update any providers further up. |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, it seems that the provided playground link is incorrect. Please upload it again. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Can I use I need to get shared data in Reactive Controllers, but using |
Beta Was this translation helpful? Give feedback.
-
I'm trying to change the state in the consumer component, but no rendering occurs. What is the correct way to update values in
@lit/context
?Lit Playground Demo Link
I tried sharing the event function as a state value to other components, which renders successfully, but what is the best way to change the state of
@lit/context
?Modified Demo Playground
I've tried changing the state through custom events, which can successfully update the value, but what approach is in line with the design of
@lit/context
?Custom Events Playground
Beta Was this translation helpful? Give feedback.
All reactions