React-native: RCTView: Shadow warnings with transparent backgrounds

Created on 14 Jan 2017  路  4Comments  路  Source: facebook/react-native

Description

RCTView throws warnings when trying to set shadows on components with transparent backgrounds.

Reproduction

Assign the following style to any Component.

const styles = StyleSheet.create({
  shadowWithWarning: {
    backgroundColor: 'transparent',
    shadowColor: '#555',
    shadowOpacity: 0.5,
    shadowRadius: 2,
    shadowOffset: {
      height: 2,
      width: 1
    }
  }

Solution

Although RCTView complains about not being able to calculate the shadow efficiently, the shadows render just fine. Would be great to be able to suppress this warning.

Additional Information

  • React Native version: 0.39.2
  • Platform: iOS
  • Operating System: MacOS
Locked

Most helpful comment

@prithsharma the warning gone after i apply shadowOpacity: 0

All 4 comments

I am also facing the same warning for backgroundColor as transparent - in fact, for backgroundColor with any opacity other than 1(using rgba).
While this commit explains the reason for the warning, but says nothing about a solution for using transparent backgrounds in a performant way other than not using transparent backgrounds.

For people who don't have enough native iOS knowledge, can someone please clarify if using transparent backgrounds on iOS is actually non-performant and should be avoided or this is a limitation of the current RN implementation of shadows(and would be fixed in a later version)?

EDIT - On closer observation, it seems this warning comes up when using transparent backgroundColor with shadow. Removing shadow(or setting shadowOpacity as 0) makes the warning go away.

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@prithsharma the warning gone after i apply shadowOpacity: 0

@prithsharma @Adamnator92
in my case it solved by putting:
shadowOpacity: 0.9

The look is almost same but removes the warning.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anchetaWern picture anchetaWern  路  3Comments

phongyewtong picture phongyewtong  路  3Comments

despairblue picture despairblue  路  3Comments

grabbou picture grabbou  路  3Comments

aniss picture aniss  路  3Comments