Skip to content

bug: Channel remounts its children when changing channels #3147

Description

@ginnymin

Describe the bug

Any children inside of Channel get remounted when switching channels

To Reproduce

Steps to reproduce the behavior:

  1. Include any component inside of Channel: <Channel><Component /></Channel>
  2. Switch to another active channel (via setActiveChannel
  3. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    WIPWork in progressbugSomething isn't workingstatus:confirmedDescribed issue has been reproduced by the repo maintainer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions