ReactJS Pitfalls #2 - using useState Instead of useRef, useCookie, useLocalForage
elibro
learningpop culturetechnologycodingcross-envcross-platformcross-platform developmentcross-platform guidesktop appdesktop app developmentdeveloperdevelopmentelectronfuture-proofgetting startedguilinuxlocalforagemantinemodern softwarenodenodejsnpmprogrammerprogrammingprogrammmingreactreact router domreactjsrustsoftwaresoftware developmentsoftware engineeringsystem traytauritutorialuiusecookieuserefusestateuxvitevscodewebappwebviewwindows
Suppose you want to persist data across sibling nodes. The next logical step is to use the parent to save the data. You may end up falling into a pit by managing the Child's state in the parent, which ends up causing performance issues. To ensure that the value held by the parent does not cause a re-render but still passes to the child on a remount, you can use useRef in the parent component and useState in the child component, OR you can avoid the parent altogether and use useCookie or useLocalForage in the child component to persist across entire app sessions rather than just sibling nodes. ... https://www.youtube.com/watch?v=IpwdQiEAWJE
2022-09-25
0.0 LBC
Copyrighted (contact publisher)
61654375 Bytes