Menu

React + Google Translate
📰

React + Google Translate

DEV Community: frontend·Shivansh Shekhar·3 days ago
#xRBTYqvC
#devtofrontend#devto#dev#react#translate
Long article (398 words) — no AI summary yet.
Reading 0:00
15s threshold

A few days ago while testing the checkout flow, I was getting "Your cart is empty." text on the cart. But there were items in it.

Other times I got "Something went wrong!" right in the middle of checkout. The reports all came from phones, so it looked like a mobile bug ...

The real clue was a tiny Google Translate icon in the address bar.

Some background: This is an online ordering system for restaurants in Germany. The ordering pages are in German. If your phone is in English, Chrome asks "Translate this page?" and plenty of people tap yes.

What Chrome does next is the problem. It doesn't edit the text. It swaps the text nodes React rendered for its own tags, and React has no idea. It still holds the old nodes.

So when React later updates that spot (the customer switches the mode to pickup from delivery, or the address "Find Location" button shows its spinner), it calls removeChild or insertBefore with a node that isn't on the page anymore.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.