{"repo":"Aminadav/react-useStateRef","free":true,"listed":false,"github":"https://github.com/Aminadav/react-useStateRef","clone":"git clone https://github.com/Aminadav/react-useStateRef.git","description":"useRef and UseState together!","language":"TypeScript","stars":197,"topics":["react","useref","usestate","javascript"],"license":"MIT","category":"ui-components","readme_excerpt":"react-useStateRef useRef and UseState together! How to use Installation As you can see it's 100% backward compatible. You can replace all your useState with this import and you will always have the latest state. Motivation: Many StackOverflow questions that people struggling to get the current state - https://stackoverflow.com/questions/54069253/usestate-set-method-not-reflecting-change-immediately - https://stackoverflow.com/questions/60438537/usestate-shows-previous-value-always - https://stackoverflow.com/questions/57847594/react-hooks-accessing-up-to-date-state-from-within-a-callback - https://stackoverflow.com/questions/55874789/using-react-hooks-why-are-my-event-handlers-firing-with-the-incorrect-state In React when functions accessing the state they receive the state from the moment the function defined - not the current state. So if the state changed, your functions and effects my use older state. Using useRef , can solve it because it have always one value. But when you update the Ref it's not re-render. See the example code: To solve it I created a new hook useStateRef See it in action: It's fully support the useState API, so you can change your useState to useStateRef and it will not break your app. Contribution - Star & fork this project. - I'm open to your contribution. - Better documentation or whatever your like. Just open a PR Other innovations by cretors: - Boti - Bot Creator Coltonos.com - Build your WhatsApp assistant in minutes","default_branch":null,"files":null,"tree":[],"storefront":"/r/Aminadav","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/Aminadav/react-useStateRef/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}