Magento module shows warning "Please do not initialize JS component in php. Do it in template" - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Friday, November 19, 2021

Magento module shows warning "Please do not initialize JS component in php. Do it in template"

I have a ViewModel class. I am getting a warning for my magento module "Please do not initialize JS component in php. Do it in template". Could someone help me out?

File: xxx/xxx/xx/xxx/xx/trackScript.phtml

<?php
/** @var xxx\xxxx\xxx\DataViewModel $helper */
?>

<script type="text/x-magento-init">
    {
        "*": {
            "trackScript": {
                "domain": "<?= $helper->getDomain(); ?>"
            }
        }
    }
</script>


source https://stackoverflow.com/questions/70025461/magento-module-shows-warning-please-do-not-initialize-js-component-in-php-do-i

No comments:

Post a Comment