Antonio De Luca
Antonio De Luca

Reputation: 73

How React renders elements?

I think my question is simple and maybe you can find it useless, but i am new to react so i am sorry for that. However if i have a json file with translation, example main.json in DE folder with a link to an image and another in EN folder that has the same keys and link to the same image. When i change the language from DE to EN does react render again the image or not? Key and value are the same.

First main.json in DE

{
  "image":"linkToImage"
}

Second main.json in EN

{
  "image":"linkToImage"
}

Upvotes: 0

Views: 35

Answers (1)

Abdullah Ismail
Abdullah Ismail

Reputation: 465

React DOM compares the element and its children to the previous one, and only applies the DOM updates necessary to bring the DOM to the desired state. Even though we create an element describing the whole UI tree on every tick, only the text node whose contents have changed gets updated by React DOM.

Resources: https://reactjs.org/docs/rendering-elements.html

Upvotes: 1

Related Questions