Skip to content

Style.t isn't enough, should we add Style.calculated? #523

Open

Description

@MoOx

As we know, all stylesheet values cannot be used in various places to add/combine styles (because they are int). Also we cannot use array() in stylesheets (runtime error).

Should we do something (at least try to) to avoid this kind of issue?

Maybe StyleSheet.create could returns Style.calculated so we cannot reuse those styles (& btw, flatten could only accept those styles ?).
That would make more complex the way we allow to use style in array for example but I wanted to give it a shot...

Also, in #520 we are saying that absoluteFill & absoluteFillObject are "the same" but they are not are one is a js object & the other is an int...

Thoughts?

Activity

  1. sgny commented on May 31, 2019

    @sgny
    Collaborator

    As we know, all stylesheet values cannot be used in various places to add/combine styles (because they are int). Also we cannot use array() in stylesheets (runtime error).

    Should we do something (at least try to) to avoid this kind of issue?

    Maybe StyleSheet.create could returns Style.calculated so we cannot reuse those styles (& btw, flatten could only accept those styles ?).
    That would make more complex the way we allow to use style in array for example but I wanted to give it a shot...

    Other than passing an array(Style.t) as the value for a StyleSheet key, I run into no problems doing any of those? I'm on RN 0.59.8, but I don't know if that makes a difference.

    Also, in #520 we are saying that absoluteFill & absoluteFillObject are "the same" but they are not are one is a js object & the other is an int...

    I referred to their definitions in the code and I see that they both are JS objects. The difference seems to me that absoluteFill has been frozen and absoluteFillObject has not, accordingly the latter can be customised. As long as pure functions are used, there should be no difference between them.

    What am I missing?

  2. MoOx commented on May 31, 2019

    @MoOx
    MemberAuthor

    Other than passing an array(Style.t) as the value for a StyleSheet key, I run into no problems doing any of those?

    Hum maybe that's the only thing. Maybe my memory has some js artifacts issue (like you cannot spread a style compiled with a StyleSheet.create as those are int & not objects).

    What am I missing?

    You are right. It seems absoluteFill has changed. They are the same now. Sooo not sure we need absoluteFillObject has this thing is documented as being a thing you can spread...

  3. sgny commented on May 31, 2019

    @sgny
    Collaborator

    You are right. It seems absoluteFill has changed. They are the same now. Sooo not sure we need absoluteFillObject has this thing is documented as being a thing you can spread...

    I think it's better to keep it in the document as someone may have been using that before moving to Reason and wonder whether a PR is in order 😃

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