Created
March 3, 2020 15:46
-
-
Save mattstauffer/c715f0cda8878eed2ef01cccd3ee80f9 to your computer and use it in GitHub Desktop.
Example of logging Laravel Livewiure component state
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
<script src="{{ asset('js/app.js') }}"></script> | |
<script> | |
let logComponentsData = function () { | |
window.livewire.components.components().forEach(component => { | |
console.log(component.name); | |
console.log(component.data); | |
}); | |
}; | |
document.addEventListener("livewire:load", function(event) { | |
logComponentsData(); | |
window.livewire.hook('afterDomUpdate', () => { | |
logComponentsData(); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated version for Livewire 2.x
Updated version for Livewire 3.x (untested)