Provide a `useStyles` method for using with React Hooks API
See original GitHub issueI imagine the API should not be too different from the HOC. The README example would look like this:
import React from "react";
import { css, useStyles } from "./useStyles";
function MyComponent() {
const styles = useStyles(({ color }) => ({
firstLink: {
color: color.primary
},
secondLink: {
color: color.secondary
}
}));
return (
<div>
<a href="/somewhere" {...css(styles.firstLink)}>
A link to somewhere
</a>{" "}
and{" "}
<a href="/somewhere-else" {...css(styles.secondLink)}>
a link to somewhere else
</a>
</div>
);
}
export default MyComponent;
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Hooks API Reference - React
This page describes the APIs for the built-in Hooks in React. ... Unlike the setState method found in class components, useState does not...
Read more >How to style components using makeStyles and still have ...
What we ended up doing is stopped using the class components and created Functional Components, using useEffect() from the Hooks API for lifecycle...
Read more >Material-UI makeStyles, useStyles, createStyles, and ...
Material-UI withStyles was the primary method for wrapping a component ... Preferably, you are using React hooks and the MUI makeStyles hook ...
Read more >Styling in React - React Hooks Handbook - Design+Code
How to style your React components using inline styling, separate stylesheets or styled-components.
Read more >Styles API - MUI System
Link a style sheet with a function component using the hook pattern. ... as React from 'react'; import { makeStyles } from '@mui/styles';...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closing based on feedback. Styles are not a stateful part of the component so it doesn’t make sense to use Hooks API for them.
For anyone landing here good news is that there is a
useStyles
hook available. //cc @noratarano