GetStream / stream-chat-react-native

๐Ÿ’ฌ React-Native Chat SDK โžœ Stream Chat. Includes a tutorial on building your own chat app experience using React-Native, React-Navigation and Stream
https://getstream.io/chat/sdk/react-native/
Other
960 stars 321 forks source link

fix: properly resolve sendMessage during memoization #2675

Closed isekovanic closed 1 week ago

isekovanic commented 1 week ago

๐ŸŽฏ Goal

We have an issue with memoization where if you do the following:

only the initial value of that state would be memoized.

Zendesk ticket: https://getstream.zendesk.com/agent/tickets/55303

๐Ÿ›  Implementation details

The reason why we wrap sendMessage in a ref is due to the fact that simply adding it to the dependency array will likely cause a ton of rerenders of components everywhere. I realise it's a hacky way to solve this, but more conventional methods such as wrapping it inside a useCallback are a bit difficult since we would need to wrap all of its other dependencies in callbacks as well, causing a cascading effect. Ideally, this should be solved by getting rid of the useMemo entirely in the MessageInputContext, but for now this'll have to do.

๐ŸŽจ UI Changes

iOS
Before After
Android
Before After

๐Ÿงช Testing

โ˜‘๏ธ Checklist

Stream-SDK-Bot commented 1 week ago

SDK Size

title develop branch diff status
js_bundle_size 442.099609375 KB 442 KB 0 B ๐ŸŸข
stream-ci-bot commented 1 week ago

:tada: This PR is included in version 5.38.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: