
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
use-transition-state
Advanced tools
useTransition + useState = useTransitionState
This hook builds on top of React.useTransition to reduce the verbose of using in conjunction with React.useState. However, the React.useTransition comes from React v18 that isn't official released yet. Which means the hook is in experimental stage and API might be changed in the near future.
To use use-transition-state, you must use react@18.0.0 or greater.
This package is distributed via npm.
$ yarn add use-transition-state
# or
$ npm install --save use-transition-state
Here's the basic concept of how it rocks.
Before:
import { useState, useTransition } from "react";
const App = () => {
const [searchQuery, setSearchQuery] = useState(null);
const [isPending, startTransition] = useTransition({ timeoutMs: 500 });
const handleInputChange = (e) => {
startTransition(() => {
setSearchQuery(getParsedData(e.target.value));
});
};
return (
<div>
<input onChange={handleInputChange} />
{isPending && "⏳ Loading..."}
<div>{searchQuery || "🔍 Start search"}</div>
</div>
);
};
After:
import useTransitionState from "use-transition-state";
const App = () => {
const [searchQuery, setSearchQuery, { isPending }] = useTransitionState(
null,
{ timeoutMs: 500 }
);
const handleInputChange = (e) => {
setSearchQuery(getParsedData(e.target.value));
};
return (
<div>
<input onChange={handleInputChange} />
{isPending && "⏳ Loading..."}
<div>{searchQuery || "🔍 Start search"}</div>
</div>
);
};
The DX of the hook is similar with React.useState. You can also access all the APIs of React.useTransition when needed.
const [
state,
setState, // A React dispatch function with `startTransition`
{
isPending,
startTransition,
setState, // A React dispatch function without `startTransition`
},
] = useTransitionState(initialState, { timeoutMs });
Thanks goes to these wonderful people (emoji key):
Welly 🤔 💻 📖 🚇 🚧 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
useTransition + useState = useTransitionState
The npm package use-transition-state receives a total of 7 weekly downloads. As such, use-transition-state popularity was classified as not popular.
We found that use-transition-state 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.