Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "Dirty" in React.js?

I am trying to understand React.js and often come across a term "Dirty" like dirty checker/checking, dirty data ,dirty model

I followed this question but could not make out what actually the term Dirty convey & why we call it dirty.

like image 349
brk Avatar asked Feb 08 '16 04:02

brk


People also ask

What is dirty in JavaScript?

Dirty MeansIf user change any data or check any box or select any value from drop down and he forget to save the data and click on exit button or closing the browser then if you want to show the message to user, before cancel or exit please save the data.

What is clean code in react?

As a JavaScript library, React inherits this problem. Clean code is a consistent style of programming that makes your code easier to write, read, and maintain. Anyone can write code that a computer can understand but good developers write clean code – code that humans can understand.

What is Sideeffect in react JS?

What are side effects in React? Side effects are not predictable because they are actions which are performed with the "outside world." We perform a side effect when we need to reach outside of our React components to do something. Performing a side effect, however, will not give us a predictable result.


2 Answers

Dirty data - the data, that have been changed recently and DOM haven't been re-rendered according to this changes yet. So dirty checking is diff between next state and current state.

like image 145
xCrZx Avatar answered Oct 15 '22 06:10

xCrZx


Dirty is just the state of the form which tells that this form has been touched by user. This does not means that form is invalid.

like image 21
Shubham Dubey Avatar answered Oct 15 '22 07:10

Shubham Dubey