Skip to content

Instantly share code, notes, and snippets.

@Braunson
Created September 12, 2024 17:58
Show Gist options
  • Save Braunson/46bd354de34132be78423c116bf24b62 to your computer and use it in GitHub Desktop.
Save Braunson/46bd354de34132be78423c116bf24b62 to your computer and use it in GitHub Desktop.
Snippet to console log when Livewire components are initialized with their data
{{-- Drop this under @livewireScripts in your layout --}}
@if (app()->environment() == 'local')
<script>
document.addEventListener("livewire:init", function(event) {
Livewire.hook('component.init', ({ component, cleanup }) => {
console.log("%cComponent: " + component.name, "font-weight:bold");
console.log(component.snapshot.data);
});
});
</script>
@endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment