Hi, I am developing a template creator with Elixir and Phoenix, it is drag and drop app and provides many predefined UI components like MegaMenu or Tabs etc. (based on https://flowbite.com).
I have a big problem that forces me to use Phoenix LiveView Hook and connect to JS client side to keep n state.
A real world and a complex UI that has nested component inside the other component, if I want to create a state which is locally I should create a state inside its parent!!.
For example:
Imagine to create a text field to take tags from a user: Sport, News, Elixir and etc.
And after that if your user click to send it should be send to the LiveView parent module, but before that where you can save these tags inside a state?
This component maybe used inside 2 the other components.
LiveViewModule --> Header Component --> SearchBox --> TagComponent
.
It is a very simple requirement you see if you want to create a state inside LiveViewModule
you should pass it to 2 another components.
The only way now, I can do this create a Hook and send to client javascript file and after that I send it back to my component
For example:
this.pushEventTo(component_id_of_myself, 'save', {
tags: ["tag1", "tag2"]
});
Other problem
I want to create a UI package like the packages in NextJS, Or react and I want to reduce my client side JS and use Phoenix LiveView instead of. with this non-existing local state in liveComponent I should tell my user install the JS package too
Just for seeing there are many UI component in my project that I need to save local state for them.
If you have any suggestion please let me know, because I do not want to create another LiveView module and call it something like this:
<%= live_render(@conn, SomeComponent, id: :some_conponent) %>
Thank you