![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
react-use-state-async
Advanced tools
A custom hook trigger call async function each dependencies changes. Support holding and updating for fetch data.
A custom hook trigger call async function each dependencies changes. Support holding and updating for fetch data.
With npm
npm install --save react-use-state-async
With yarn
yarn add react-use-state-async
import * as React from "react";
import useStateAsync from "react-use-state-async";
export default function App() {
const [url, setUrl] = React.useState("");
const { isLoading, data, error, setData, fetch } = useStateAsync(() => {
return new Promise((resolve) => {
setTimeout(() => {
resolve("api data");
}, 1000);
});
}, [url]);
return (
<div>
<button onClick={() => setUrl("https://urlapi.com")}>Change url</button>
<button onClick={() => fetch()}>Refetch api</button>
<button onClick={() => setData("new data")}>Update data</button>
{isLoading ? <p>Loading</p> : <p>Loaded</p>}
{data && <p>{data}</p>}
{error && <p>{error}</p>}
</div>
);
}
useStateAsync(
callback: () => any | async () => Promise<any>,
dependencies: Array<any>
)
parameter | type | description |
---|---|---|
isLoading | boolean | `true` if the callback function is running |
data | any | the data is returned in callback function |
error | any | the error is thrown in callback function |
setData | function | update `data` state |
fetch | function | trigger call callback function |
FAQs
A custom hook trigger call async function each dependencies changes. Support holding and updating for fetch data.
The npm package react-use-state-async receives a total of 2 weekly downloads. As such, react-use-state-async popularity was classified as not popular.
We found that react-use-state-async demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.