Skip to content

SkeletonPlaceholder has black background on Android that cannot be changed #151

Description

@trooperandz

After upgrading to React Native version 0.79+, I started getting a black background on the SkeletonPlaceholder component on Android that will not go away. I tried multiple combinations of <View> containers in different positions with different backgrounds with no successful result. See examples below of applying a specific red background on iOS and Android so that you can see the difference in behavior.

Also see below my code sample. Note that I also tried adjusting my Android theme so that it is not dark and the problem still persisted. In addition, when the component first loads, it looks correct without the black background; then it flashes and the black persists.

Android

Image

iOS

Image

Example code

export const SkeletonListItem: React.FC = () => {
  const theme = useAppSelector(state => selectTheme(state));

  const lineStyle = {
    borderRadius: 12,
    height: 12,
  };

  return (
    <View style={styles.container}>
      <SkeletonPlaceholder highlightColor={theme.skeletonHighlight}>
        <View style={styles.wrapper}>
          <View style={styles.image} />

          <View
            style={{
              marginLeft: 16,
              width: 140,
            }}
          >
            <View style={lineStyle} />
            <View
              style={{
                ...lineStyle,
                marginTop: 10,
                width: 235,
              }}
            />
          </View>
        </View>
      </SkeletonPlaceholder>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    // backgroundColor: '#fff',
    backgroundColor: 'red',
    width: '100%',
    marginBottom: 26,
    paddingHorizontal: 6,
  },
  image: {
    borderRadius: 18,
    height: 36,
    width: 36,
  },
  wrapper: {
    backgroundColor: 'red',
    alignItems: 'center',
    width: '100%',
    flexDirection: 'row',
  },
});

_Note that I also tried using <SkeletonPlaceholder.Item> per the documentation example, and I got the same black background.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions