What is the correct way to cite an inner class?

Exploring the world of Material UI styling for the first and probably last time, I find myself in a bit of a bind. In my current code setup, I have a question regarding the following structure:

.map(section => (
  <Section className={classNames(classes.section, section.class)}>
    <div className={classes.content}>
    ...
    </div>
  </Section>
))

The sections are generally named like Section1, etc. To customize these styles, I attempted the following approach:

{
  section: {},
  Section1: {
    backgroundColor: 'black',
    '& img': { ... }
    content: { border: '1px solid pink' }
  }
}

However, despite my efforts, the pink border does not seem to be applying as expected.

I did notice that images within the sections were styled correctly. The generated code revealed:

.makeStyles-Section1-415 {
  content: [object Object];
}
.makeStyles-Section1-415 img {
  margin-left: 400px;
}

It appears that the MUI class generator struggles with producing inner class names. This presents a challenge when trying to target specific elements using selectors like & .content.

So, the big question remains: what is the secret to making this styling setup work seamlessly?

p.s.

If resorting to something drastic like:

{
  Section1Content: {}
}

is truly the only solution, then it may just be time to consider scrapping this styling system altogether.

Answer №1

the solution is:

  Block1: {
    '& $box': { border: '1px solid blue' }

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

Tips for creating space between two fluid divs

I'm currently facing an issue with the spacing between two child divs inside a parent div. The web page needs to be responsive for different screen widths, but the vertical space between the left and right divs is not behaving as expected. I am using ...

Place the h1 text inside of a div tag for organization

Here is an example of HTML code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <tit ...

Adjusting the image height to match the container height while preserving its original aspect ratio

Is there a method, using CSS alone, to adjust an image's height to fit its container while preserving aspect ratio and allowing the overflow of width to be concealed? It may seem like a complex set of requirements, but is it achievable? Essentially, I ...

Invoke a function on React whenever the context is updated

Within my functional component, I have a scenario where it returns another function: function Lobby() { const user_context = useContext(UserContext) return ( <div>{renderData(user_context.state.data)}</div> ) } export default L ...

Exploring How React Handles State Updates Within an Asynchronous Block

When I clicked the async change button in this code, I expected the output to be: num1: 6 num1: 7 Since each state update is done in the then() block so React does not batch the updates. But instead, I got: num1: 6 import React, { useState } from "rea ...

What is the reason behind the code breaking when a newline is added between `return` and `(`?

After investigating my query, it seems that a peculiar issue arises in the code where setState fires and render method gets hit, but nothing rerenders The code functions correctly when there is no newline between the return statement and opening parenthes ...

Develop a step-by-step chart for implementing in React

I am currently creating a web application to assist parents in monitoring their children's vaccination schedule. I am looking for a way to implement a table that allows operations to be performed at the cell level, such as clicking on a cell to mark a ...

Learn how to customize the auto complete component in ReactJS using Material-UI to ensure it always fully covers the

Having some trouble with auto complete and dropdown display. My API returns a large amount of data, and when I type in the autocomplete search bar, the dropdown covers the text input. I attempted to modify the style: <AutoComplete hintText="For e ...

Upon launching the application, it will automatically update itself and then proceed to open its own interface

After successfully developing an application with react and electron, I encountered a strange issue during packaging. Once the app is open, a notification prompts an automatic update to version 3.0.2. However, upon relaunching the application, I am redir ...

Tips for simulating localStorage in TypeScript unit testing

Is there a method to simulate localStorage using Jest? Despite trying various solutions from this post, none have proven effective in TypeScript as I continue encountering: "ReferenceError: localStorage is not defined" I attempted creating my ...

Intro.js is not compatible with React and Remix.run

I am currently working on implementing onboarding modals for header links using intro.js within a React environment. Below is the code snippet: import { useState, type FC } from 'react' import type { Links } from '../types' import &apo ...

Issues with the performance of a React web app in production mode

This situation feels like the classic "works fine on my machine" issue. A key client is noticing sluggish performance in our React web app (graphql, mobx, and apollo). The slowdown seems to occur after prolonged usage (hours), leading me to suspect a poten ...

Creating a dynamic animation effect on a div with a changing number of child elements

Currently, I am utilizing the nganimate library and have implemented an animation that affects the max-height property of a div. Here is a snippet of my code: CSS .sublist.ng-hide { max-height: 0; } .sublist { max-height: 1300px; overflow: hidden; ...

Using Next.js and mongoose to include ObjectId's in an array before saving a new object

For days now, I've been struggling to figure out how to create a new object (Group) that contains selected objectId's (User). The group model is defined as follows: import mongoose from 'mongoose'; const groupSchema = new mongoose.Sche ...

The Material UI component successfully loads the options data list from the server response, however, it fails to return the selected value when an option

My goal is to dynamically populate my country and province select component based on server response data. The process begins with the user selecting a country, which triggers a request to the server using the selected country's id. The server respond ...

React Next - ReferenceError: window object is undefined

Within my coding framework, I have implemented two distinct reusable functions that both utilize the window.localStorage.getItem method. The first function, userByToken, encounters an error due to its use of window, while the second function, useValidateTo ...

Differences between MobX local state and global state

I am currently working on a React project using mobx to manage the application state. For dump components that interact with external data sources (such as ajax calls, filtering or mapping arrays), I simply manipulate the data in those components. Howeve ...

Adding extra space to the list items in CSS causes the text to become static and unaffected by fluctuations in the line-height

Here's the problem I'm facing: I have a basic list consisting of a shopping cart, login and user registration. I want to adjust the position of the list by adding padding, but every time I do so, the line height also increases. Is there a workaro ...

Receiving a 404 error from an API endpoint in Next.js indicating an error

The issue arises when the ID is not present in the database, resulting in a 404 error. I attempted to implement a check with "if (res.status == 404)" but it seems to trigger the error prior to validation. export const getServerSideProps = async (contex ...

Issue with React Router causing data not to load again

I have encountered an issue where clicking on the navigation bar to a different id path does not fetch the related data. Below is the code snippet for reference: import React, { Component } from 'react'; import { Route, Switch } from "react- ...