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

Support props argument for StyleSheet.create #98

Closed
kentcdodds opened this issue Jul 5, 2016 · 4 comments
Closed

Support props argument for StyleSheet.create #98

kentcdodds opened this issue Jul 5, 2016 · 4 comments

Comments

@kentcdodds
Copy link
Contributor

kentcdodds commented Jul 5, 2016

Inspired by @rofrischmann's fela. It appears to be a pretty slick API. Something like:

StyleSheet.create(props => ({
  bar: {
    fontSize: props.big ? '25px' : '15px',
    // etc.
  }
}))
@jlfwong
Copy link
Collaborator

jlfwong commented Jul 5, 2016

I think this is syntactic sugar. Just use functions:

const styles = (props) => StyleSheet.create({
    bar: {
        fontSize: props.big ? '25px' : '15px'
    }
});

Then use as styles({big: true}).bar. Could be memoized appropriately.

So it may indeed be useful syntactic sugar, but IMO, does not belong in Aphrodite core.

@bananatranada
Copy link

Is it not recommended to call StyleSheet.create() within the render function?

@kentcdodds
Copy link
Contributor Author

If you need to, then it's never been a problem for me.

@devDanielCespedes
Copy link

Thanks aloooot @jlfwong

I think this is syntactic sugar. Just use functions:

const styles = (props) => StyleSheet.create({
    bar: {
        fontSize: props.big ? '25px' : '15px'
    }
});

Then use as styles({big: true}).bar. Could be memoized appropriately.

So it may indeed be useful syntactic sugar, but IMO, does not belong in Aphrodite core.

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

4 participants