Skip to content

Trying to use dynamic color causes an unhandled JS exception #413

Closed

Description

Environment

"react-native": "0.62.2",
"react-native-macos": "^0.61.37"
node v14.2.0
yarn 1.22.0
Xcode 11.5
Build version 11E608c

Issue

I was trying to use dynamic colors in my app, ex:

icon: {
    color: {
      dynamic: {
        light: `black`,
        dark: `white`,
      },
    },
  },

when saving the file, I got a runtime exception:

Unhandled JS Exception: TypeError: undefined is not an object (evaluating '_reactNative.Appareance.getColorScheme')

I'm guessing this functionality is not implemented yet?

#335 might be related to this issue

(Write your steps here:)

  1. Try to use dynamic colors

Expected Behavior

No crash, actually be able to use colors based on current OS setting

Actual Behavior

Screenshot 2020-05-23 at 14 05 34

Activity

  1. tom-un commented on May 24, 2020

    @tom-un
    Collaborator

    Hi! The {dynamic: {light: '', dark: ''} } color value type does work. However, the feature was added in this fork back in version 0.59. Its probable that after merging in .60 and .61 that new color values were added and we failed to refactor them to use the new ColorValue type.

    Which color prop exactly do you want to use the dynamic color on? It should not be a problem to add it.

    Also, this won't be an on going issue after we merge in react-native 0.63 because I contributed the mechanism upstream as the PlatformColor API react#27908. So after we're in sync with .63, we will no longer be broken by new color props being added upstream.

  2. ospfranco commented on May 26, 2020

    @ospfranco
    Author

    Just a background color of a view, if it won't be an issue you can close this ticket and I will test it when new version is out

  3. ospfranco commented on May 30, 2020

    @ospfranco
    Author

    I just tested again, and I must have made an error somewhere because the dynamic notation is working fine, sorry for any confusion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions