-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
Hook demos #15032
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
Comments
I will gladly help on this, I want to get more comfortable with the monorepo, so this task seems to be perfect for me, but unfortunately, I do not have too much free time. I guess until the end of the week I won't be able to help (but I can not promise anything). |
@apanizo Don't worry, you can contribute at your own pace :) |
Am I understanding correctly that the |
Yes, it does. You need to provide the props as a first argument of useStyles. |
Thanks for your answer. I'm not sure I understand which props you're talking about. And that makes me think that I couldn't find any documentation on overriding styles for a component styled with |
function Component ({ classes }) {
...
}
export default withStyles(styles)(Component); is equivalent to const useStyles = makeStyles(styles);
function Component (props) {
const classes = useStyles(props);
...
}
export default Component; |
The override works the same for the user. The implementation just has to make sure it calls useStyles with props. This is IMO a better API since you now have full control over your CSS API (expose nothing, everything, only some classes etc). |
@fzaninotto Correct, I'm working on it in #15140. |
I'm closing, this is not important enough. We will take care of removing React.Component from the demos in #15231. As for the styles, it would make sense to migrate all the demos to either use the Box or styled-components, hopefully. |
With #13497 we got a lot of demos using the hook API. We want to continue this effort with the goal to have all demos using the hook API, only. We want to encourage a single pattern for each problem, not many.
styles
People are wondering when to use withStyle, makeStyles or the Box component.
Most of the time, you should consider using the hook API.
There is one case where withStyles can be preferred over makeStyles. In the following case, using the hook API would create more boilerplate:
makeStyles has many advantages over withStyles, it requires less boilerplate, it's faster, it's easier to type, it's easier to move & delete.
If you want to make contributions to this repository, we would appreciate you helping us.
Getting started
TL;DR: Use #15031 as example workflows.
./docs/src/pages/demos/lists/lists.md
and find the section. You're looking for a{{ "demo": "some-path" }}
block:docs:typescript:formatted
to update the JavaScript version.While working
If you're stuck at any point you can still submit the PR. A maintainer will take a look and provide guidance.
This migration task is highly repetitive, we should be able to largely automate it with the appropriate search & replace.
The text was updated successfully, but these errors were encountered: