Replies: 3 comments
-
How are you doing this? It would be helpful to see some code to better understand what you're trying to do. Do you mean to say that the Lit element should be updating its own property and you want the React component to only read it? Then you should get a ref to the Lit element and read the property directly rather than try and sync a React state. If you need the React component to respond when the property changes (assuming it needs to be something more than DOM update), I'd rather have the component dispatch and event that you listen from in the React component, instead of trying to get it to call a set state function re-render. |
Beta Was this translation helpful? Give feedback.
-
Hey @augustjk, thanks for the quick reply ! I added some code above. The issue with the ref is that changes doesn't trigger re-renders, which is the reason why I was hoping I could do it the "normal react way". Ideally, I would like to avoid end users (that will import the Lit Component) to do something as extra as creating an |
Beta Was this translation helpful? Give feedback.
-
Okay I was making a mistake. It actually works as expected. |
Beta Was this translation helpful? Give feedback.
-
Hello all,
I'm using
lit
&@lit/react
.I'm passing a function that update my React Component state to my web component and then call
this.requestUpdate
. Well, as you would expect, it doesn't work. I can see that internally the function has been called but my React Component doesn't re-render. Is this normal ? My code looks like that:React Component:
Lit Component:
If so, could one of you kind people help me out and shows me an example on how to do that ? 🙏
In case I'm doing this completely wrong, basically what I want to do is having a shared state between my React Component and LitElement. The state should never change in the parent, it would be a read-only state. Modified by the LitElement.
Thanks a lot for the help guys !
Beta Was this translation helpful? Give feedback.
All reactions