1.0.2 • Published 4 months ago
async-use-state v1.0.2
async-use-state
A React hook for managing state with async callbacks.
Installation
npm install async-use-state
usage
import React from "react";
import asyncUseState from "async-use-state";
const App = () => {
const [count, setCount] = asyncUseState(0);
const increment = () => {
setCount(count + 1, (updatedCount) => {
console.log("State has been updated:", updatedCount);
// Perform async actions here
});
};
return (
<div>
<p>Count: {count}</p>
<button onClick={increment}>Increment</button>
</div>
);
};
export default App;