Styling ReactJS Components with CSS Styling

I am a complete beginner to React and I seem to be facing an issue with rendering CSS properly.

The react class, App, that I have should display a Card with a progress tracker on it.

var App = React.createClass({
render: function () {
    var pushNotifications = _.map(this.props.pushNotifications, function(value, key, notification) {
        return (
            <div className="row" key={1}>
                <div className="col-sm-12">
                    <Card>
                        <h1>Title</h1>
                        <div className="clearfix">
                            <ol class="progtrckr" data-progtrckr-steps="5">
                                <li class="progtrckr-done">Order Processing</li>
                                <li class="progtrckr-done">Pre-Production</li>
                                <li class="progtrckr-done">In Production</li>
                                <li class="progtrckr-done">Shipped</li>
                                <li class="progtrckr-todo">Delivered</li>
                            </ol>
                            <div className="pull-right">
                                <p>Total: {iOSTotal}</p>
                            </div>
                        </div>
                     </Card>

Definition of Card:

 module.exports = React.createClass({
    render: function() {
        return (
            <div className="card">
                {this.props.children}
            </div>

        )
    }
});

The proctrckr CSS is located in the css/build file as follows:

    ol.progtrckr {
  display: table;
  list-style-type: none;
  margin: 0;
  padding: 0;
  table-layout: fixed;
  width: 100%; }

... (CSS continues)

However, when I run this code, it just displays a regular ordered list without applying any of the CSS styling I wrote.

Any assistance or guidance would be highly appreciated.

Thank you,

Answer №1

Swap out class with className. A common jsx pitfall. Documentation.

Because JSX is JavaScript, using names like class and for as XML attribute identifiers is not recommended. Instead, React DOM components require property names such as className and htmlFor, respectively.

<ol className="progtrckr" data-progtrckr-steps="5">
  <li className="progtrckr-done">Order Processing</li>
  <li className="progtrckr-done">Pre-Production</li>
  <li className="progtrckr-done">In Production</li>
  <li className="progtrckr-done">Shipped</li>
  <li className="progtrckr-todo">Delivered</li>
</ol>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Merge two arrays by matching their corresponding identifiers

I have 2 separate arrays that I need to merge. The first array looks like this: const Dogs[] = [ { id: '1', name: 'Buddy' }, { id: '2', name: 'Max' }, ] The second one: const dogAges[] = [ { id: '4&ap ...

Unable to set selected property in React Material-UI menu item

One issue I'm facing is setting the selected prop using react mui menu item. In a multiple select menu list, there's a field called allValues that, when clicked, should toggle the selection of all menu items. The code for this functionality looks ...

The image slide change feature ceases to function properly when incorporating two separate functions

I have a function that successfully changes the image of a container every 5 seconds. However, I am facing an issue when trying to add 2 containers side by side and change their images simultaneously. When I run the functions for both containers, only one ...

Validating forms in React using ES6 syntax

Just starting out with react js and utilizing es6 coding along with material ui. Below is a snippet of my code: class Components extends React.Component { render() { return ( <div style={styles.root}> <GridList cols={2} ...

Do you require a lightbox for a white text box set against a semi-transparent black background?

Currently, I am in the process of developing a Chrome extension that will be compatible with my Android app. As part of this development, I need to code the HTML/CSS for the extension. The main functionality of the extension allows users to add tags to a s ...

What is the best way to showcase Json API content on an HTML page?

I possess a strong proficiency in html and css, however I lack experience in utilizing javascript. My aim is to showcase the date received from an API onto an html page Despite several attempts, I have not been able to achieve success yet. var getJSON ...

Using the react-bootstrap library, I have successfully integrated a Navbar

The navigation bar below is not functioning properly, and the container is causing the links to lead to a 404 error page. I have attempted writing it in various formats: <Nav.Link href="" >Name</Nav.Link> <Nav.Link href={"&qu ...

Customized link routing / Deep linking

I need some help. I am managing a standard website and I want to redirect custom URLs to specific pages when visitors access the site. For instance: - index.html should point to custom_index.cfm?custom_id=1&page_id=1&inc=index - about.html shou ...

Using Javascript to retrieve form data from a separate file

I am struggling with my HTML and JavaScript files to collect data. Despite my efforts, the function is not executing properly. Below is the code I have been working on: HTML File : <form class="form-newsletter"> <div class="form-group"> ...

After updating the External SS, the background vanishes

There appears to be an issue with a page that I designed. I originally wrote the CSS code internally within the <style type="text/css>...</style> section, including a background image, and all was working fine initially. However, after transf ...

Guide to utilizing the bootstrap grid system to stack below a width of 480px

I have been grappling with this issue, but unfortunately, there seems to be a lack of information on how to resolve it. I have gone through numerous old posts where individuals are "modding" the files and creating their own col-ms (medium-small) that stack ...

The sizing of cards in Bootstrap is not uniform

I'm currently working on a page layout using Bootstrap. I've included 3 cards in a row, but they are not displaying at equal sizes for some reason. The content within the cards, including headings and images, seems to be affecting their overall s ...

Using React and Jest to mock a default function imported from an npm package

I am attempting to mock the "readXlsxFile" function from the npm package "read-excel-file". My issue is most likely with the line jest.spyOn(readXlsxFile, "default"). I have tried various async/await combinations and also used the "act" method from react t ...

Tips for creating CSS3 animations in Angular triggered by mouse clicks

I'm working with a span that utilizes a Bootstrap icon. My goal is to fade out and fade in the same element (span) on click, while toggling the class (icon). There's a boolean variable called showLegend which determines whether or not to animate ...

Guidelines on navigating a blank page using the Nuxt-js method

I have run into an issue in my Nuxt.js project where I need to open a link in a new target when a user clicks a button. Despite trying various solutions, I haven't been able to find a workaround within the Nuxt.js framework itself. <a :href=&qu ...

Adjusting varying column heights in Material UI for consistent display

I am currently working on a React project where I have implemented a two column layout with Material Design. The issue I am facing is that the right textbox needs to be taller than the left one, but adjusting the number of rows also affects the position of ...

Angular's Validator directive offers powerful validation capabilities for reactive forms

Referenced from: This is the approach I have experimented with: custom-validator.directive.ts import { Directive } from '@angular/core'; import { AbstractControl, FormControl, ValidationErrors } from '@angular/forms'; @Directive({ ...

Extracting textual information from Wikipedia through iframes?

Currently, I am working on a website project utilizing Squarespace. This site will feature multiple pages dedicated to individuals who have reached a level of notability worthy of having their own Wikipedia page. With over 150 pages planned, manually writi ...

What is the best way to make the div inside the table cells expand to fill the available space?

I'm having trouble making the inner divs within table cell divs expand and fit their parent div without overlapping the next cell below it. Check out the sandbox for reference I've outlined the areas in grey where I want the cells to be filled. ...

Running "npm run build" is not recognizing the updates made

Recently, I encountered an issue while building my React app. Everything was working fine until yesterday. Despite running npm run build to ensure the app is in a production-ready state, any changes I make on the page are not reflected. Surprisingly, whe ...