A section of the code was commented out that was responsible for updating the chatSections state depending on the incoming props. This kept all messages in the chat from displaying, since chatSections is an empty array on initial render and would never get re-computed.
The original code used a method called componentWillReceiveProps that has since be renamed to UNSAFE_componentWillReceiveProps, which is probably the reason it was commented out. This PR uses the static method getDerivedStateFromProps to adjust the chatSections state in a safe manner. It only updates the state if it detects a difference in the number of messages displayed.
A section of the code was commented out that was responsible for updating the
chatSections
state depending on the incoming props. This kept all messages in the chat from displaying, sincechatSections
is an empty array on initial render and would never get re-computed.The original code used a method called
componentWillReceiveProps
that has since be renamed toUNSAFE_componentWillReceiveProps
, which is probably the reason it was commented out. This PR uses the static methodgetDerivedStateFromProps
to adjust thechatSections
state in a safe manner. It only updates the state if it detects a difference in the number of messages displayed.This resolves issue https://github.com/jkk/shinkgs/issues/233