![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@lawcket/react-websocket
Advanced tools
A slim Websocket implementation for React 16+. The libray uses the standard browser WebSocket so 'should' be supported in React-Native.
npm install --save @lawcket/react-websocket
or
yarn add @lawcket/react-websocket
Example:
import React, { useState } from 'react';
import Websocket from '@lawcket/react-websocket';
const Messages = () => {
const [messages, addMessage] = useState([]);
return (
<Websocket
url='wss://...'
retry
onOpen={({ send }) => console.log('open')}
onClose={({ code, reason }) => console.log('closed', code, reason)}
onMessage={({ send, data }) => console.log('message', data)}
onError={(error) => console.log('error', error)} >
{({ send, close }) => {
return (
<pre>{JSON.stringify(messages, null, 2)}</pre>
);
}}
</Websocket>
);
}
Name | Type | Description | Default |
---|---|---|---|
url | string | The websocket url to connect to | |
protocol | string | The protocol for the websocket to use | |
retry | boolean | If an error occurs, should it reconnect | true |
onOpen | function | Notifies when the connection has been opened | |
onMessage | function | Notifies when an incoming message has been received | |
onClose | function | Notifies the connection was closed | |
onError | function | Notifies of an error with the connection, will close the connection |
Parameter | Type | Description |
---|---|---|
send | function(any) | A function to send data to the server |
Parameter | Type | Description |
---|---|---|
data | any | Incoming message (usually stringified JSON data) |
send | function(any) | A function to send data to the server |
Parameter | Type | Description |
---|---|---|
error | Error | The error that occured during connection or usage |
Reference: Close codes & reasons
Parameter | Type | Description |
---|---|---|
code | number | The close code sent by the server |
reason | string | The reason the connection was closed |
FAQs
A slim React websocket implementation
We found that @lawcket/react-websocket 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
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.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.