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

Benefit of running inline through css? #96

Open
merlinstardust opened this issue Aug 24, 2017 · 3 comments
Open

Benefit of running inline through css? #96

merlinstardust opened this issue Aug 24, 2017 · 3 comments

Comments

@merlinstardust
Copy link

In the readme, you have this example

<div {...css(styles.container, { padding })}>

What benefit is providing by running the plain object through the css function?

From looking at the code, it just passes these objects into the style prop. But why not do this directly? Wouldn't that be more performant?

@ljharb
Copy link
Collaborator

ljharb commented Aug 24, 2017

The interface might return a style prop; but if it's aphrodite, it'll return a className prop.

@merlinstardust
Copy link
Author

I see that. But I'm wondering why pass the plain object in at all. Why not pass it directly to the style prop?

<div {...css(styles.container)} style={{ padding }}>

From looking at the internals, this would do the same thing, but it would save you from looping over extra arguments.

@ljharb
Copy link
Collaborator

ljharb commented Aug 24, 2017

The whole point of react-with-styles is to write components that are interface-agnostic.

An interface, even with { padding } passed in, might choose not to create an inline style at all - our native CSS interface does that, for example. In that case, no style prop would ever exist.

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