mweststrate / use-st8

Single-function alternative for React.useState
MIT License
234 stars 7 forks source link

Does it solve a problem of crazy re-rendering on any state change #23

Open NetLancer opened 1 year ago

NetLancer commented 1 year ago

Hi @mweststrate and thanks for the invention, looks cute :)). My case is, trying to implement following logic: On webpage load first see if my localStorage contains the needed information, and if so - fine, use it. Else - apiFetch it, use and also save it in localStorage for subsequent use. The information amount's not very small but rarely changes (why i want localStorage) I need some kinda intermediate storage (on frontend) which possibly less memory consuming and does not cause page re-render on any state change in the background like useState does (or did, based on my stale react knowledge :)). (By the way, i'm using react fullstack framework with graphql & prisma). The idea is to store some amount of information from (localStorage | apiCall) at any given moment, and the UI will depend on that store. Would it be a suitable solution ? Thanx a lot ))