question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bubble message text color does not dynamically change

See original GitHub issue

Issue Description

MessageText color does not dynamically change when changing the color property on the Bubble component.

Steps to Reproduce / Code Snippets


const renderBubble = (props) => {
    // theme is a hook that updates the colors based on the device's colorScheme value ('light' or 'dark'). 
    const { theme } = useTheme();
    
    return (
      <Bubble
        {...props}
        wrapperStyle={{
          left: { backgroundColor: theme.colors.bubble }, // Changes dynamically 
          right: { backgroundColor: theme.colors.bubble }, // Changes dynamically
        }}
        renderMessageText={(props) => {
          return (
            <MessageText
              {...props}
              textStyle={{
                left: { color: theme.colors.white }, // Does not change dynamically
                right: { color: theme.colors.white },
              }}
            />
          );
        }}
      />
    );
  };

Expected Results

The text should change its color (re-render the component). For example, theme.colors.white is white when the colorScheme is ‘light’ and black when the colorScheme is ‘dark’.

Testing this with the background color property for the Bubble component and it works fine if we provide shouldUpdateMessage={() => true}. However, no matter what we tried (e.g. adding theme property to extraData prop) the color property of MessageText does not change.

Additional Information

  • Nodejs version: v15.14.0
  • React version: 16.13.1
  • React Native version: Expo’s latest for SDK 41
  • react-native-gifted-chat version: 0.16.3
  • Platform(s) (iOS, Android, or both?): both
  • TypeScript version: N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
husam-qbcommented, May 22, 2021

Solved this issue by implementing our own MessageText component as a hook. The problem seems to be with the componentShouldUpdate function does not get executed when shouldUpdateMessage returns true. It only propagates down to the Bubble component.

We prefer that this is fixed in the library so we don’t have to maintain our own custom component.

0reactions
fukemycommented, Jun 27, 2022

hi can u provide some codes?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change the background color of a single chat bubble ...
I'm trying to dynamically change the chat bubble background. After doing a lot of researching I thought this was the correct approach but...
Read more >
Messages now has dynamic colors in the conversation bubbles
Messages bubble colors in iOS 15, any way to change hues slightly without jailbreaking? (the green for SMS is blinding to me).
Read more >
Changing color dynamically in the HTML not working - Database
I want each thing shown in the Repeating Group, to show a different (or same color) depending on things in the database. Therefore...
Read more >
Problem with text alignment in a chat bubble layout
What I need to achieve is that message text is aligned to the left (in case of left-to-right languages) but since message TextView...
Read more >
How to change color dynamically from front end in Bubble.io ...
Hi, Welcome to Bubble.io tutorialIn this bubble.io tutorial , You will learn how to create an app without coding, how to build a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found