Avoid UseEffect in react to execute on every updates - طراحی سایت|نرم افزار اندروید|IOS|مرورگران

Avoid UseEffect in react to execute on every updates

Avoid UseEffect in react to execute on every update

React virtual DOM is one of the most important features of reactjs which is has high performance impact on react applications , but this feature is kind of knife that could be awful if misused .

A misused case of that ,wouldn’t be care of when components should be updated (class or functional) or made react to unlimited rerender in a loop .

useEffect (()=>{},[]) hook came to take care of effects and changes in functional component , this hook would be executed in two different senario :

1-Execue once a time when component mounted if pass empty array to second argument

2-Execute each time something get change like props or other hooks or even parent reRender in some conditions

But if we need just know about a particular changes like a particular props or variable we have to pass that into second argument like this

const [count,setCount]=useState(0);

useEffect (()=>{do something},[count])

نظرات (5)

  • erotik izle 1399-08-23 از 1:06 ق.ظ پاسخ

    Hello Dear, are you genuinely visiting this web site daily, if so then you will definitely get pleasant knowledge. Kati Mandel Howlond

  • erotik 1399-08-24 از 3:55 ق.ظ پاسخ

    This article is actually a fastidious one it helps new internet users, who are wishing for blogging. Faythe Christoper McKee

  • erotik 1399-08-25 از 9:27 ق.ظ پاسخ

    I like the efforts you have put in this, appreciate it for all the great content. Arleyne Arlan Huoh

  • porno 1399-09-19 از 12:06 ب.ظ پاسخ

    I like it whenever people get together and share opinions. Great blog, keep it up. Pennie Olin Haymes

  • porno 1399-09-19 از 6:34 ب.ظ پاسخ

    I really like your writing style, fantastic info , regards for posting : D. Jillene Ruddy Center

نظر خود را بگذارید

آدرس ایمیل شما منتشر نخواهد شد.*