rescript-react-native icon indicating copy to clipboard operation
rescript-react-native copied to clipboard

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

Open MoOx opened this issue 6 years ago • 3 comments

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?

MoOx avatar May 31 '19 08:05 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...

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?

sgny avatar May 31 '19 12:05 sgny

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...

MoOx avatar May 31 '19 12:05 MoOx

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 😃

sgny avatar May 31 '19 19:05 sgny