Renderhook Cannot Received Dispatched Event

Hello,

I am using a renderhook to include some custom JS on a specific page using:

FilamentView::registerRenderHook(
            PanelsRenderHook::BODY_START,
            fn (): string => Blade::render('@livewire(\'star-j-s\')'),
            scopes: [
                ListOrders::class,
            ]
        );


The JS renders on the page correctly. I have confirmed that it renders properly using:

<div>
</div>

<script>
  console.log('rendered');
</script>


I cannot handle any dispatched events. I have tried:

document.addEventListener('livewire:init', () => {
        Livewire.on('paymentSuccessful', event => {
})
// and ...
$wire.on('paymentSuccessful') // this throws an error saying $wire is undefined
// and...
window.addEventListener('paymentSuccessful', event => {

})


Do I need to modify the StarJS Livewire component? What am I doing wrong?

Thanks!
Was this page helpful?