Reputation: 674
I'm trying to pass my current index in useStyles hook to display my component depending of this index like this :
const useStyles = makeStyles(theme => {
console.log(theme);
return {
root: {
flexGrow: 1,
display: theme.props.currentIndex !== 0 ? 'none' : void 0
}
};
});
I saw that we can pass props to useStyle hook, so I passed my current value to use it in makeStyles :
const AcademicDegresPanel = props => {
const classes = useStyles(props);
console.log(props.currentIndex)
return (
<Grid container className={classes.root}>
Degrés academique
</Grid>
);
};
But when i log my theme, it has not the currentIndex in props key :
palette: {common: {…}, type: "light", primary: {…}, secondary: {…}, error: {…}, …}
props:
__proto__: Object
How can I use my current index in makeStyles instead of using inline style ?
Upvotes: 0
Views: 233
Reputation: 2958
Use it like this:
const useStyles = props => makeStyles(theme => ({/* ... */ })();
or
const useStyles = props => {
// style construction
return makeStyles(style)();
};
Upvotes: 2