
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.
react-use-observable
Advanced tools
Use observables with react hooks in an very easy way.
yarn add react-use-observable
import React from 'react';
import { useObservable } from 'react-use-observable';
import * as rxjs from 'rxjs';
import { map, startWith } from 'rxjs/operators';
interface IProps {
start: number;
}
export const Counter: React.FC<IProps> = ({ start }) => {
const [ value ] = useObservable(() => {
return rxjs.interval(1000).pipe(
map(v => v + start),
startWith(start)
);
}, [/* deps */])
return (
<p>Started with undefined, value: {value}</p>
);
}
| Hook | Return | Description |
|---|---|---|
| useObservable(Func, DepsArray) | Value, Error, Completed | Run the observable function on every deps change, the first value will be undefined |
| useRetryableObservable(Func, DepsArray) | Value, Error, Completed, RetryFunc | Same useObservable, but the last value of return is a retry function to rerun the observable function, useful when an error happens or do a refresh |
| useMappedObservable(Func, MapFunc, DepsArray) | Value, Error, Completed | Same useObservable, but with a internal map and a distinctUntilChanged, useful to do less renders |
| useCallbackObservable(Func, DepsArray) | CallbackFunc, Value, Error, Completed | Same useObservable, but the first result is the callbackFunction and run the observable function only when it is called, useful to use in a submit or button's click and keep the unsubscribe on unmount |
FAQs
Use rxjs observables with react hooks
The npm package react-use-observable receives a total of 165 weekly downloads. As such, react-use-observable popularity was classified as not popular.
We found that react-use-observable 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.