App reviews, troubleshooting, and recommendations
I am trying the shopify remix app tutorial for embedded apps but I am getting an error
Unexpected Server Error Error: shopify.toast can't be used in a server environment. You likely need to move this code into an Effect.
I haven't done any coding I just did init and then npm run dev
Solved! Go to the solution
This is an accepted solution.
All those who are facing this issue comment
This is an accepted solution.
If you have code like this:
useEffect(() => {
if (showMessage) {
shopify.toast.show('message');
setShowMessage(false);
}
}, [setShowMessage, showMessage, shopify.toast]);
Change it to this:
useEffect(() => {
if (showMessage) {
shopify.toast.show('message');
setShowMessage(false);
}
}, [setShowMessage, showMessage, shopify]);
It's the `shopify.toast` useEffect dependency that is causing the problem. The solution is to change the dependency to `shopify` (without the `.toast`).
same issue here . brand new embedded app -
same here
same problem
Same problem here
in app/routes/app._index.jsx or tsx
Commenting out that line doesn't work for me. Even after I killed and re-ran my dev server.
edit: comment out the entire useEffect hook and it should run.
This is an accepted solution.
All those who are facing this issue comment
Commenting out the code as a temporary workaround. However, this doesn't address the root cause and simply postpones the problem.
It appears that the useEffect hook itself might not be triggering correctly on mobile devices. Updating state variables from within the useEffect does not work.
The toast is not imported properly no issue with hooks since it's boilerplate I think shopify would fix it in next update
This is an accepted solution.
If you have code like this:
useEffect(() => {
if (showMessage) {
shopify.toast.show('message');
setShowMessage(false);
}
}, [setShowMessage, showMessage, shopify.toast]);
Change it to this:
useEffect(() => {
if (showMessage) {
shopify.toast.show('message');
setShowMessage(false);
}
}, [setShowMessage, showMessage, shopify]);
It's the `shopify.toast` useEffect dependency that is causing the problem. The solution is to change the dependency to `shopify` (without the `.toast`).
this should be the accepted answer @rahular
We recently spoke with Zopi developers @Zopi about how dropshipping businesses can enha...
By JasonH Oct 23, 2024A big shout out to all of the merchants who participated in our AMA with 2H Media: Holi...
By Jacqui Oct 21, 2024We want to take a moment to celebrate the incredible ways you all engage with the Shopi...
By JasonH Oct 15, 2024