Do the hooks work the same for a live_view as for a live_component?

Hello, how are you? I have a question. The hooks work the same for a live_view as for a live_component.

my question arises from a component that uses a hook to show tags

in the live_view it shows it without problems but in the live_component it lets me use it but it doesn’t show the selected tags and I think that maybe the problem is that it is not incorporating the hook and I have to do it manually

and in case you have to make adaptations to the hook to be usable in the live_component
Where can I find information on necessary modifications?

It’s unclear if you are talking about JS hooks or LiveView hooks. Either way, it’s very hard to help without seeing some code.

1 Like

the hook is a next js

and what is happening to me is that it behaves in different ways in a live_view (in which it works correctly)
and in a live_component in which the logic of the component works but not the part of the js that I think is what makes the tags work

The code you shared is from a library, so it’s not a huge help. I would suggest opening an issue there on how to use it with live components. My guess is that you aren’t sending the updated state from the LiveView to the component, but I can’t know that without seeing the component code (and also I don’t know this library).

If currently I asked the author if he had a case similar to mine… but my question is if a Js hook designed for a live_view (which I think is the case for this one) would be equally functional on a live_component, something to confirm or dismiss the fact that the hook is the problem

because the component itself works for me, what doesn’t work for me are the tags and the only place I saw that they handled it is in the hook.

equally the logic of the component is handled here:

The only notable difference between the behavior in a live view vs a live component is that you have to make sure that the target is set correctly for the live component if you are sending events back and forth between the JS and the live component.

that is to say that basically the live_component needs an event that makes it update… when marking an option for example, and possibly not having that event and not updating, does it cause me not to show the selected tags?