Skip to content

Commit

Permalink
Fix deprecation of componentWillReceiveProps
Browse files Browse the repository at this point in the history
  • Loading branch information
lahsivjar committed Mar 4, 2020
1 parent b1aca61 commit f6b2199
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Report any issues or bugs to <https://github.com/lahsivjar/react-stomp/issues>

## Changelog

### 5.0.0
- Update react from 16.5.0 to 16.6.3
- Fix deprecation of `componentWillReceiveProps`

### 4.3.0
- Update handlebar dependency

Expand Down
28 changes: 20 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-stomp",
"version": "4.3.0",
"version": "5.0.0",
"description": "React websocket component with STOMP over SockJS",
"main": "./dist/client.js",
"nyc": {
Expand Down Expand Up @@ -62,8 +62,8 @@
"mocha": "^6.0.0",
"nyc": "^14.0.0",
"prop-types": "^15.6.2",
"react": "^16.8.1",
"react-dom": "^16.8.1",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"sinon": "^8.0.0"
},
"dependencies": {
Expand Down
10 changes: 6 additions & 4 deletions src/client.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import difference from 'lodash/difference'
/**
* React component for SockJS-client with STOMP messaging protocol.
*
* @version 4.1.0
* @version 5.0.0
* @author [lahsivjar] (https://github.com/lahsivjar)
* @see {@link https://stomp.github.io/|STOMP}
* @see {@link https://github.com/sockjs/sockjs-client|StompJS}
Expand Down Expand Up @@ -120,7 +120,9 @@ class SockJsClient extends React.Component {
return false
}

componentWillReceiveProps (nextProps) {
/* eslint camelcase: ["error", {allow: ["UNSAFE_componentWillReceiveProps"]}] */

UNSAFE_componentWillReceiveProps (nextProps) {
if (this.state.connected) {
// Subscribe to new topics
difference(nextProps.topics, this.props.topics)
Expand Down Expand Up @@ -269,9 +271,9 @@ class SockJsClient extends React.Component {
* @param {Object} [opt_headers={}] additional headers for underlying STOMP client
* @public
*/
sendMessage = (topic, msg, opt_headers = {}) => {
sendMessage = (topic, msg, optHeaders = {}) => {
if (this.state.connected) {
this.client.send(topic, opt_headers, msg)
this.client.send(topic, optHeaders, msg)
} else {
throw new Error('Send error: SockJsClient is disconnected')
}
Expand Down

0 comments on commit f6b2199

Please sign in to comment.