Skip to content

Revert the Platform.os changes? #778

@cknitt

Description

@cknitt

In #771 and #774, I changed Platform.os from an abstract type to a polymorphic variant.

This allows us to use the more convenient

if Platform.os === #ios {
  ...
}

instead of

if Platform.os === Platform.ios {
  ...
}

which is fine.

It also allows us to do

switch Platform.os {
  | #ios => ...
  | #android => ...
  | _ => ...
}

which is problematic as it compiles to something like

var match = ReactNative.Platform.OS;

if (match === "ios") {
  ...
} else if (match === "android") {
  ...
} else {
  ...
}

which will break Metro bundler's inlining (see a previous discussion in #239 for more details about this).

So I am not sure anymore if we should introduce a breaking change that invites people to use a problematic pattern. What do you think @MoOx?

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