Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

90
Views
React useStyles not applying styles

I am trying to create an E-Commerce platform in React JS. I am following tutorials from Youtube. I don't know whats the problem but the styles from the styles components are not applying properly, cross-checked the code with the tutor's code several code but was unable to figure out as what is the issue. Can anybody spot the issue?

Products.jsx Component

import React from 'react'
import {Card, CardMedia, CardContent, CardActions, Typography} from '@material-ui/core'
import { IconButton } from '@material-ui/core'
import { AddShoppingCart} from '@material-ui/icons'
import useStyles from './styles'

const Product = ({product}) => {

    const classes = useStyles();
    return (
        <Card className={classes.root}>
            <CardMedia className={classes.media} image={product.image} title={product.name} />
            <CardContent>
                <div className={classes.CardContent}>
                    <Typography variant="h5" gutterBottom>
                        {product.name}
                    </Typography>
                    <Typography variant="h5">
                        {product.price}
                    </Typography>
                </div>

                <Typography variant="body2" color="textSecondary">{product.description}</Typography>

                <CardActions disableSpacing className={classes.CardActions}>
                    <IconButton aria-label="Add to Cart">
                        <AddShoppingCart/>
                    </IconButton>
                </CardActions>
            </CardContent>
        </Card>
    )
}

export default Product

Styles. js file is here

import { makeStyles } from "@material-ui/core";

export default makeStyles(() => ({
    root: {
        maxWidth: "100%"
    },
    media: {
        height: 0,
        paddingTop: '56.25%'
    },
    carrdActions: {
        display: 'flex',
        justifyContent: 'flex-end'
    },
    cardContent: {
        display: 'flex',
        justifyContent: 'space-between'
    }
}))

Any help is appreciated!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

This must be classes.carrdActions:

           <CardActions disableSpacing className={classes.CardActions}>

Because you defined it like this:

  carrdActions: {
    display: 'flex',
    justifyContent: 'flex-end'
},

Same with classes.CardContent

about 4 years ago · Juan Pablo Isaza Report

0

please import makeStyles from this:

    import { makeStyles } from "@material-ui/core/styles";
     // not
    import { makeStyles } from "@material-ui/core";

I'm sure your problem will be solved;

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!