Skip to content

ListItem backgroundColor persists after it's changed in the theme #3655

@Nantris

Description

@Nantris

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
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    ThemingIssue related to Theme Feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions