
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@mediamonks/use-channels
Advanced tools
A set of hooks for using the Channels package in a React project.
npm install @mediamonks/use-channels
ChannelsProvider
: component that creates a Channels
instanceuseChannels
: returns the Channels
instanceuseVolumeChange
: adds listeners for volume changesusePanningChange
: adds listeners for pan changesusePlayingSounds
: keeps track of sounds that are being playedBefore being able to use useChannels
, somewhere in your React application (probably at the root of the app tree), a <ChannelsProvider>
component must be present. This will create a Channels
instance and provide it through React Context to the component's children.
import { ChannelsProvider } from '@mediamonks/use-channels';
export const ParentComponent = () => {
return <ChannelsProvider
soundsExtension="mp3"
soundsPath={'path/to/files'}
>
<App />
</ChannelsProvider>
}
The available props for the
ChannelProvider
are taken directly from theChannels
constructor (of whichever version you have installed), so check the Channels package for more information.
The children
of the ChannelsProvider
can either be a ReactNode
(as shown in the example above), or a function that returns a ReactNode
. In the latter, the created Channels
instance is provided as the first parameter:
export const ParentComponent = () => {
const [isLoadComplete, setIsLoadComplete] = useState(false);
return <ChannelsProvider
soundsExtension="mp3"
soundsPath={'path/to/files'}
>
{(channelsInstance) => {
channelsInstance.loadSounds().then(() => setIsLoadComplete(true))
return isLoadComplete ? <App /> : <Spinner />;
}}
</ChannelsProvider>
}
The Channels
instance from the ChannelsProvider
is available in all child components by using the useChannels
hook:
import { useChannels } from '@mediamonks/use-channels';
export const ChildComponent = () => {
const channelsInstance = useChannels();
const onClick = () => {
channelsInstance.play('my-sound');
}
return <button onClick={onClick}>play!</button>
}
useVolumeChange
makes listening to volume changes a bit easier. It has an optional target
prop, which can either be a Channel
or a PlayingSound
. When omitted, changes refer to the main volume.
import { useVolumeChange } from '@mediamonks/use-channels';
// listen to main volume changes
useVolumeChange({
onChange: (value: number) => {
// ...
},
});
// listen to channel volume changes
useVolumeChange({
target: myChannel,
onChange: (value: number) => {
// ...
},
});
usePanningChange
is nearly identical to useVolumeChange
but listens to changes in panning values.
The usePlayingSounds
hook keeps track of a list of all the currently playing sounds.
import { usePlayingSounds } from '@mediamonks/use-channels';
const playingSounds = usePlayingSounds();
FAQs
React hook for using Channels
The npm package @mediamonks/use-channels receives a total of 0 weekly downloads. As such, @mediamonks/use-channels popularity was classified as not popular.
We found that @mediamonks/use-channels demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.