jonassiewertsen / statamic-livewire

A Laravel Livewire integration for Statamics antlers engine
83 stars 14 forks source link

Nested components getting re-rendered #18

Closed ryanmitchell closed 2 years ago

ryanmitchell commented 2 years ago

I'm using this add on to build a checkout component, which in turn has some nested components (basket view and country/state selector).

The issue is that when the nested component (eg country/state) emits an event that affects the parent component (checkout), the child components get re-rendered. If I rebuild the components in blade rather than antlers this does not happen.

Is this a known issue? Is there a work around?

jonassiewertsen commented 2 years ago

I haven't reproduced your issue, but I know that Livewire is working best with Blade, so I am sure that you are right.

If using nested components, I would recommend using Blade, as Livewire is working best and fastest with it. I can't tell if we will rewrite the rendering for Antlers with Livewire at some point in this addon, but it's not planned at the moment. I am simply afraid of the maintenance burden.

There might be cases, where it's easiest to render something in Antlers. In those cases, I am personally including an Antlers partials for this part and am using Blade for the rest. This is a little hacky (don't tell anybody), but does speed things up and works great. This may be a good workaround for you.

I would love to give a better answer, but that's how things are right now 🤷‍♂️

ryanmitchell commented 2 years ago

Thanks for the comment - it's good to have it confirmed that blade is the way to go. Thanks again for the add on - it's really helpful.