react-stomp icon indicating copy to clipboard operation
react-stomp copied to clipboard

Should we move away from UNSAFE_componentWillReceiveProps

Open IMM9O opened this issue 4 years ago • 3 comments

I want to address some adjustment improvement to remove the need for use UNSAFE_componentWillReceiveProps as it throws an error with react 17 and use shouldComponentUpdate method instance

and here my suggestion, it ok?

  shouldComponentUpdate (nextProps, nextState) {
    if (this.state.connected) {
      // Subscribe to new topics
      difference(nextProps.topics, this.props.topics).forEach((newTopic) => {
        this._log('Subscribing to topic: ' + newTopic)
        this._subscribe(newTopic)
      })

      // Unsubscribe from old topics
      difference(this.props.topics, nextProps.topics).forEach((oldTopic) => {
        this._log('Unsubscribing from topic: ' + oldTopic)
        this._unsubscribe(oldTopic)
      })
    }
    return false
  }

IMM9O avatar Nov 17 '20 11:11 IMM9O

Also seeing the same warning in browser console, would really like to see an update like this pulled in. An otherwise awesome tool here.

AnthonyNGarcia avatar May 26 '21 19:05 AnthonyNGarcia

Have been away from this project for a while, will take a look into this sometime next week.

lahsivjar avatar May 31 '21 15:05 lahsivjar

@lahsivjar Do you think this could be resolved if a pull request was made with the proposed changes? This could potentially close #133 and #195

IncPlusPlus avatar Apr 01 '22 23:04 IncPlusPlus