Clock2, useEffect and useState Hook
 
This writing is continued article from previous one. This  article explains how to use setInterval function and Hooks to make mobile clock application with react native. 1. setInterval function setInterval  is basic function included in JavaScript. It calls call-back function at every intervals (milliseconds). setInterval  function returns id value, so when it is not used anymore, clearInterval  should be used to prevent unnecessary memory use.   const  id  =  setInterval(callBackFunction,  interval)  callBackFunction  =  ()  =>  {}   clearInterval(id)    For the app to show the real time in every second unit, code will be as below. But below example calls setInterval  function whenever App is newly rendered every second. setInterval  should be called only at the first time when rendered. For this kind of issue, useEffect hook is used.   export  default  function  App()  {    let  time  =  new  Date ()    const  id  =  setInterval(()  =>  {      time  =  new  Date ()   /...
 
