Describe the bug
Any children inside of Channel get remounted when switching channels
To Reproduce
Steps to reproduce the behavior:
- Include any component inside of
Channel: <Channel><Component /></Channel>
- Switch to another active channel (via
setActiveChannel
- Notice inner component remounts
Expected behavior
Children of Channel do not remount.
Example repro code
const Component = () => {
useState(() => {
console.log("Component mount");
});
return null;
}
// stream client and channelId (string) passed in
const Example = ({ channelId, streamClient }) => {
const { setActiveChannel } = useChatContext();
useEffect(() => {
if (!streamClient) return;
const channel = streamClient.channel("messaging", channelId);
setActiveChannel(channel);
}, [streamClient, setActiveChannel, channelId]);
return (
<Channel>
<Component />
</Channel>
);
};
Package version
- stream-chat-react: 13.14.4
- stream-chat-css:
- stream-chat-js: 9.38.0
Desktop (please complete the following information):
- OS: MacOS
- Browser: Chrome and Safari
Describe the bug
Any children inside of
Channelget remounted when switching channelsTo Reproduce
Steps to reproduce the behavior:
Channel:<Channel><Component /></Channel>setActiveChannelExpected behavior
Children of
Channeldo not remount.Example repro code
Package version
Desktop (please complete the following information):