Magento – Uncaught SyntaxError: Unexpected token u in JSON at position 0

magento2messagesreview

Review submission message You submitted your review for moderation. is not showing up immediately after submitting a review. In fact, it will not show up on the product view page at all, and I must navigate to any other page for the message to render.

There seems to be some JS error that prevents fully loading the product view page. Request to get .../pub/static/frontend/Theme/default/en_US/Magento_Ui/template/messages.html isn't on the product view page, apparently due to the JS error displayed in the console. I'm guessing this is likely the issue..

console log

Looks like the object passed to run is undefined.. Where do I go debug this from here? On other pages, one of the objects passed in here is messaged with the review submission message.

Best Answer

Add in you current layout catalog_product_view.xml :

    <referenceBlock name="product.review.form">
        <arguments>
            <argument name="jsLayout" xsi:type="array">
                <item name="components" xsi:type="array">
                    <item name="review-form" xsi:type="array">
                        <item name="component" xsi:type="string">Magento_Review/js/view/review</item>
                    </item>
                </item>
            </argument>
        </arguments>
    </referenceBlock>

Hope this helps