How can I create ReactiveController standlone instance If web component used in recursive #3246
-
I am creating web component like tree, so that web component is used recursively, I want to maintain status which node is selected if use expand any level of node. One of idea is we can use ReactiveController to maintain state, but Its create each instance for each node, do you have any suggestion how we can do that ? and I have bind keyboard event to expand and close node in each node using ReactiveController controller but if I Open 3rd level tree item then keyboard event called 3 times, I have remove listeners but still its called 3 times. any suggestion on it ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I am not 100% certain I understand what you mean, but it sounds like a slot would be more what you need: https://lit.dev/docs/components/shadow-dom/#slots |
Beta Was this translation helpful? Give feedback.
-
Heya, there are many approaches to this, but it seems like there are solutions out there for you that may already solve this like If you want an example of how to implement something like this, here is an example of a controller for the redux state manager: https://lit.dev/playground/#gist=b7e3c1e58657a3b130521f17b1a15af2 The concepts are there and you can likely swap out redux for another solution or a custom solution |
Beta Was this translation helpful? Give feedback.
I am not 100% certain I understand what you mean, but it sounds like a slot would be more what you need: https://lit.dev/docs/components/shadow-dom/#slots