Skip to content

Hook demos #15032

Closed
Closed
@oliviertassinari

Description

@oliviertassinari

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:

const CustomTableCell = withStyles(theme => ({
  head: {
    backgroundColor: theme.palette.common.black,
    color: theme.palette.common.white,
  },
  body: {
    fontSize: 14,
  },
}))(TableCell);

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.

  1. Set up your fork (See 'getting started" in the contributing guide).
  2. Choose a demo you want to convert. For this example, we'll use: https://next.material-ui.com/demos/lists/#nested-list
  3. go to ./docs/src/pages/demos/lists/lists.md and find the section. You're looking for a {{ "demo": "some-path" }} block:
  {{"demo": "pages/demos/lists/NestedList.js"}}
                               ^^^ Name of the demo file in `./docs/src/pages/demos/lists/` 
  1. Make sure a TypeScript variant is available. If it's not, you should handle TypeScript demos #14897 first in a different pull request.
  2. Only migrate the TypeScript variant. The TypeScript variant of the demo (.tsx) is used to generate the JavaScript variant (.js).
  3. run docs:typescript:formatted to update the JavaScript version.
  4. Submit a PR

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsImprovements or additions to the documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions