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.

ListItem backgroundColor persists after it's changed in the theme

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Explain what you did

Define a backgroundColor for ListItem.containerStyle like below:

const rneTheme = createTheme({
  components: {
    ListItem: {
      containerStyle: {
        backgroundColor: background,
      },
    },
  }
})
<ThemeProvider theme={rneTheme}>{children}</ThemeProvider>

Expected behavior

When the color in the theme changes, the backgroundColor for ListItem should change, but instead it persists in the old color.

Describe the bug

The backgroundColor for ListItem fails to update when the theme is updated. This can be easily tested in any setup that uses theming and defines separate colors for light/dark modes.

In our case, we noticed the issue occurred when toggling from light to dark, or the reverse. The color will remain as it was in the originally applied theme, never changing.

Steps To Reproduce

const rneTheme = createTheme({
  components: {
    ListItem: {
      containerStyle: {
        backgroundColor: background,
      },
    },
  }
})
<ThemeProvider theme={rneTheme}>{children}</ThemeProvider>

And then use a ListItem somewhere, and toggle dark/light mode in your app.

Screenshots

Light mode colors persist on ListItem even in dark mode. If app is started in dark mode, then the problem is reversed.

image

Your Environment

`npx @rneui/envinfo`
  ```
    System:
OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (4) x64 AMD Ryzen 7 5800X 8-Core Processor
Memory: 2.08 GB / 19.51 GB
Container: Yes
Shell: 5.8.1 - /usr/bin/zsh

Binaries: Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.17.0/bin/yarn npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm Watchman: 4.9.0 - /usr/bin/watchman Managers: Apt: 2.4.7 - /usr/bin/apt pip3: 22.2.2 - ~/.local/bin/pip3 Utilities: CMake: 3.22.1 - /usr/bin/cmake Make: 4.3 - /usr/bin/make GCC: 11.2.0 - /usr/bin/gcc Git: 2.38.1 - /usr/bin/git SDKs: Android SDK: API Levels: 31, 32, 33 Build Tools: 30.0.3, 31.0.0, 33.0.0 System Images: android-31 | Google APIs Intel x86 Atom_64, android-31 | Google Play Intel x86 Atom_64 IDEs: Nano: 6.2 - /usr/bin/nano VSCode: 1.68.1 - /usr/bin/code Languages: Bash: 5.1.16 - /usr/bin/bash Perl: 5.34.0 - /usr/bin/perl Python3: 3.10.6 - /usr/bin/python3 Databases: SQLite: 3.32.2 - /home/me/Android/Sdk/platform-tools/sqlite3 Browsers: Chrome: 106.0.5249.61 Firefox: 106.0 Monorepos: Yarn Workspaces: 1.22.19 Lerna: 5.6.2 ```

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
arpitBhallacommented, Oct 28, 2022

Hey, I am working on it, will make a release as soon as it’s fixed.

4.0.0 will be available once few more critical issues are resolved.

1reaction
Slapboxcommented, Oct 25, 2022

@arpitBhalla thanks again for your help and great work!

Unfortunately I discovered the same issue with the buttons. See #3665.

PS, is there any ETA for the next release candidate version? I noticed they were coming out monthly, or even more frequently, but it’s been almost 3 months since the last release candidate. And is there any ETA for the final release of 4.0.0?

Read more comments on GitHub >

github_iconTop Results From Across the Web

react native - Background color on List Item doesn't work?
And if i put a container with flex:1 around it you see the color but it is below the ListItem itself. Very weird,...
Read more >
Theming · React Native Paper
To support custom themes, paper exports a Provider component. ... You can change the theme prop dynamically and all the components will automatically...
Read more >
How to change background color of selected item in a listview ...
Forms when click on ListView ViewCell background color changed to orange , but not initialized to a color. A listener could be attached...
Read more >
Global Styling with Material-UI Theme Overrides and Props
We will avoid breaking the Material-UI components' contracts. ‍. Brand Components vs. Theme Overrides and Props. What is a Brand Component? When ......
Read more >
Storybook: background change on prop change
It would be nice if the background changed color automatically when the backgroundColor prop changed its value. That is why we are consuming...
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