
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
react-socket.io
Advanced tools
react socket.io provider Higher Order Component, passing the socket to children
react socket.io provider Higher Order Component, passing the socket to children
Install from npm
import SocketProvider from 'react-socket.io';
const socketOptions = {
url: <redisUrl>,
ioOptions: <redisOptions>,
initialSocketEvents: [],
onConnectEvents: [],
onDisconnectEvents: [],
loadingComponent: <CustomLoadingComponent>
};
ReactDOM.render(
<Router history={browserHistory}>
<Route path="/" component={SocketProvider(App, socketOptions))} />
<Route path="/login" component={unauthComponent} />
</Router>,
document.getElementById('root')
);
In App the following props are now exposed:
socket
addSocketEvent
emitSocketEvent
removeSocketEvents
You can give the socket provider default socket events that needs to be run directly after the socket connection is made. The on event callback returns the socket. These socket events must have the following format:
{
type: 'on',
name: 'connect',
callback: socket => store.dispatch(socketConnected(socket))
},
// emit has the options property instead of callback.
{
type: 'emit',
name: 'client:init',
options: {}
}
Specify what functions should be run when a socket connection is made.
onConnectEvents: [
socket => store.dispatch(socketConnected(socket))
]
Specify what functions should be run when a socket is disconnected.
onDisconnectEvents: [
store.dispatch(userLogoutClient()),
store.dispatch(socketRemove())
]
A Custom loading component that can be used to show the user the socket is reconnecting. This component gets a prop isConnecting injected. This can be used to show a difference between reconnecting and offline.
// The prop is injected by default.
<loadingComponent isConnecting={isConnecting} />;
Install node_modules
used in ./src
:
$ npm i
Compile ./src
with Babel:
$ npm run compile
To watch for changes in ./src
run:
$ npm run watch
Babel will compile ./src
on changes.
This project is licensed under the terms of the MIT license.
FAQs
react socket.io provider Higher Order Component, passing the socket to children
The npm package react-socket.io receives a total of 0 weekly downloads. As such, react-socket.io popularity was classified as not popular.
We found that react-socket.io 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.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.