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

153
Views
react js : children style doesn't show

I tried to create a component 'Card' and use it like a container. the code work well without 'card'. when I tried to add it the 'Card.css' and expense-item in ExpenseItem.css doesn't work

this is 'ExpenseItem.js':

import Card from './Card';
import ExpenseDate from './ExpenseDate';
import './ExpenseItem.css';

function ExpenseItem(props) {

  return (
    <Card className='expense-item' >

        <ExpenseDate date={props.date} />
      <div className='expense-item__description'>
        <h2 >{props.title}</h2>
        <div className='expense-item__price'>{props.amount} Da </div>
      </div>
      
    </Card>
  );
}

export default ExpenseItem;

this is 'Card.js':

import './Card.css';

function Card(props){
    const classes ='card'+props.className;
    return <div className={classes}> {props.children} </div>;
}
export default Card;

and this is 'Card.css':

.card {
  border-radius: 12px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.25);
}

and finally this is 'ExpenseItem.css':

.expense-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    margin: 1rem 0;
    background-color: #ff0000;
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need a space between card and the class name in the classes variable. Because there is no space, the className attribute in the card component is just cardexpense-item.

This is how it should look:

const classes = 'card '+props.className;
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!