Created
September 12, 2024 17:58
-
-
Save Braunson/46bd354de34132be78423c116bf24b62 to your computer and use it in GitHub Desktop.
Snippet to console log when Livewire components are initialized with their data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{-- 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