Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MoOx opened this issue May 31, 2019 · 3 comments
Open

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

MoOx opened this issue May 31, 2019 · 3 comments

Comments

@MoOx
Copy link
Member

MoOx commented May 31, 2019

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?

@sgny
Copy link
Collaborator

sgny commented May 31, 2019

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?

@MoOx
Copy link
Member Author

MoOx commented May 31, 2019

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

@sgny
Copy link
Collaborator

sgny commented May 31, 2019

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants