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

Would you consider supporting multiple statements? #61

Open
BiosSun opened this issue Feb 27, 2021 · 2 comments
Open

Would you consider supporting multiple statements? #61

BiosSun opened this issue Feb 27, 2021 · 2 comments

Comments

@BiosSun
Copy link
Contributor

BiosSun commented Feb 27, 2021

I want use JSS in my project demos, It's used as follows:

import React from 'react'
import {createUseStyles} from 'react-jss'

const useStyles = createUseStyles({
  box: {
    color: 'red'
  }
})

export default function Box({ children }) {
  const classes = useStyles()
  return <div className={classes.box}>Hello</div>
}

But currently React View does not support writing multiple statements.

First, we add a return before the first statement, and we will delete export default, and modify the variable declaration statement, leaving only the initial value part.

This will make the above demo code error.

I wonder if it is possible to simply replace the export default statement with a return statement. If there is no export default statement in the code, then convert the last statement to a return statement.

If you think this is feasible, then I can implement it and submit a pull request.

@tajo
Copy link
Contributor

tajo commented Feb 28, 2021

You can probably just move useStyles into Box fn. It's not very pretty but should work?

@BiosSun
Copy link
Contributor Author

BiosSun commented Feb 28, 2021

Yes, it works. but I don't want to write this kind of code in the demo, it is not good.

In addition, in my ideas, the problem of spread attribute can also be solved.

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