The Stepper StepIconComponent prop in MUI is experiencing issues when trying to render styles from the styles object, leading to crashes in the app

Struggling to find a way to apply the styles for the stepper component without using inline styles. I attempted to replicate Material UI's demo, but encountered an error. The code from Material UI's demo that I want to mimic is shown below:

https://i.sstatic.net/Wldd8.png

Here is the code snippet they provided:

const ColorlibStepIconRoot = styled('div')(({ theme, ownerState }) => ({
  // Styles here
}));

function ColorlibStepIcon(props) {
  // Code goes here
}

I thought of avoiding the HOC component and trying something else, as seen in Material UI's demo. They import styled from:

import { styled } from '@mui/material/styles';

However, I received an error when using it. Instead, I attempted to utilize it within the styles object following the pattern with withStyles, but encountered this error:https://i.sstatic.net/YME1K.png

My code snippet looks like this:

// My code

Answer №1

Your code contains 2 bugs that need to be fixed. In the icon component:

<img className={classes.checkListImage}

The correct rule name you defined earlier is checklistImage, not checkListImage. So make sure to update it to:

<img className={classes.checklistImage}

Secondly, the use of classes from the Checklist component may cause confusion as it's also used in the ColorlibStepIcon:

const ColorlibStepIcon = ({
  icon,
  completed,
  className,
  theme,
  /*classes <-- this classes is undefined which overrides real classes
   passed from above, better remove it */
}) => {

https://codesandbox.io/s/69756889-material-uis-stepper-stepiconcomponent-prop-having-trouble-with-rendering-style-17idu?file=/demo.js

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

What is the process for converting a CSV file to JSON format using node.js?

I am working on converting a CSV file from Clash Royale into an array. The CSV file has over 40 properties in its header or data. For example: name level count upgrade cost common 14 5, 20, 50, 100 rare 12 50, 150, 400, 1000 Below is my node.j ...

Designing webpages by superimposing text onto images with customizable positioning

My current project involves developing an HTML document with a floor plan image as the main layer. On top of this image, I need to display employee names extracted from a database and positioned on the map based on a location variable within the database ...

Is opting to exclude the language file from the main bundle a viable strategy for minimizing the overall bundle size?

As I brainstorm ways to optimize my app's bundle size, I had a thought and would appreciate some feedback. Do you think it's advisable to exclude the language file altogether from the main bundle of an application? If your app is large with nume ...

The website code lacks a dynamically generated <div> element

When using jQuery to dynamically add content to a "div" element, the content is visible in the DOM but not in the view page source. For example: <div id="pdf"></div> $("#btn").click(function(){ $("#pdf").html("ffff"); }); How can I ensur ...

Creating a two-column layout in CSS using div elements instead of tables allows for

Why is it so challenging to create a two-column form layout using CSS? All I'm trying to achieve is: Name: John Smith Age: 25 Description: A long text that should wrap if it exceeds the border, while still aligning with the first l ...

There was an issue with the SidebarController function being undefined, as it was expected to be a function

I'm encountering two issues with my demo: Error: [ng:areq] Argument 'SidebarController' is not a function, received undefined http://errors.angularjs.org/1.2.26/ng/areq?p0=SidebarController&p1=not%20aNaNunction%2C%20got%20undefined ...

Tips for transmitting variable values through a series of objects in a collection: [{data: }]

How to pass variable values in series: [{data: }] In the code snippet below, I have the value 2,10,2,2 stored in the variable ftes. I need to pass this variable into series:[{data: }], but it doesn't seem to affect the chart. Can anyone guide me on ...

Tips for troubleshooting my website?

After making some updates to my website, I noticed that an ajax script is no longer functioning properly. Since I hired someone else to write the code, I'm not sure how to troubleshoot it. Initially, this is what it should look like: When you select ...

Issue with CSS pseudo-elements :before and :after in Internet Explorer

I am attempting to create a heading with lines on both sides, but I am facing an issue where it only seems to work on the left side in IE. Check out the code here h2 { position: relative; overflow: hidden; text-align: center; } h2:before, h2:afte ...

Looping through JSON objects using for loop

I am trying to implement a for loop with the following json data. The console.log function is working properly, but when I use it in the javascript function, it does not work as expected. I want the for loop to be functional within the javascript function ...

Combining dropdowns, nav-pills, and separate links in Bootstrap 4 to create a seamless horizontal layout

Trying to achieve a layout in Firefox where everything is displayed in one single horizontal row. This includes the label Dropdown, dropdown box itself, bootstrap nav-pills menu, and separate link. Code snippet: (jsfiddle: https://jsfiddle.net/aq9Laaew/16 ...

Definition of TypeScript type representing the value of a key within an object

As I delve into defining custom typings for a navigation library using TypeScript, one challenge that has me stumped is creating a navigate function. This function needs to take the Screen's name as the first argument and the Screen's properties ...

Multiple card displays not working with Javascript Fetch API

I wrote a script that retrieves data from a URL and then organizes it into tables for display to the user. Initially, the script functioned correctly. However, I decided to enhance its flexibility by introducing two parameters - name and HTML div name wher ...

Information about Doughnut chart in React using the react-chartjs-2 package

Is there a way to write text directly on a Doughnut using react-chartjs-2? Most answers I came across explain how to place text in the center of a Doughnut, but not actually on it. Here is an image for reference: ...

Best practices for updating the value of a specific key within an object that contains recursion in JavaScript/TypeScript

I have a tree component that uses the following data structure type TreeNode = { id: string, parentId: string, renderer: () => React.ReactNode, expanded: boolean, children?: Array<TreeNode>, } Now, I am looking to add functionality for ...

What is the best method to override the CSS transition effect with JavaScript?

I am trying to implement a CSS transition where I need to reset the width of my box in advance every time my function is called. Simply setting the width of the box to zero makes the element shrink with animation, but I want to reset it without any animati ...

What sets apart withStyle from withTheme in material ui?

I recently started learning web development and I'm currently experimenting with material-ui. I've noticed that some demo codes utilize withStyles while others use withTheme. Can someone clarify the distinctions between them? Thank you in advance ...

Retrieve information from the NodeJs server pertaining to the previous 10-minute timeframe

While working on a project where I needed to fetch and display data from a website within the past 10 minutes that meets a certain condition, I initially thought of storing it in a global variable. However, I realize that this may not be the best practice. ...

I'm curious why this is happening. Is it due to the default padding or margin property?

I am currently working on a website project. The genre navigation menu is located in the bottom left container, and I had to use a negative margin property to position the li elements correctly. However, there seems to be an unexpected top padding of aro ...

Tips for adjusting the Tab Order in Material-UI Tabs

Can anyone help me with changing the tab index of the MUI Tabs? I want it so that when the Tab key is clicked, it selects the first tab first, then the second, and so on. ...