React does not recognize the use of `.css` or `.scss` files for styling

Recently, I encountered an issue with my React code where inline styles were working fine:

render() {
    return (
        <div style={{ fontSize: 48 }}>LOLOLO</div>
    )
}

However, when I tried using index.css (which defines .me { font-size: 48 }), it seemed to have no effect:

import styles from './index.css'
render() {
    return (
        <div className={styles.me}>LILILILALALA</div>
    )
}

I'm puzzled by this behavior. Can anyone provide insight into what might be causing this problem?

For reference, here is the content of my tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": [
    "src"
  ]
}

Answer №1

Here is the solution:

import './index.scss'
render() {
    return (
        <div className="me">LILILILALALA</div>
    )
}

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

Prevent scrollbar from appearing while splash page loads

Looking for help with a script to create a splash/intro page loader. $(function(){ setTimeout(function() { $('#splash').fadeOut(500); }, 6000); }); The current script hides the intro page after 6 seconds, ...

Troubleshooting JWT Session Errors in Next Auth / NextJS

Hello, I am in need of assistance with the authentication process using the getServerSession method of next-auth. I am utilizing the magic link login with the prism adapter. The frontend session seems to be working fine and the sessions are correctly stor ...

Is there a way to implement a scrollbar that only scrolls through one specific column in an HTML table?

I need help adding a scrollbar to a specific column in an HTML table. Take a look at this scenario https://jsfiddle.net/6wpdc4tL/: https://i.stack.imgur.com/svzIg.png This table should have two scrollbars, one for the light blue SCROLL column and another ...

Tips for replacing spaces with &nbsp; in a string using ReactJS and displaying it in HTML

<div className="mt-2 font-sidebar capitalize"> {item.title} </div> item.title can vary and be any string retrieved from the backend, such as "all products", "most liked", "featured items", etc. I am looking for a solution to subst ...

Moving from one page to another

I am attempting to create a transition effect between sections within a single-page application. All the sections are contained on the same page, with only one section displayed at a time while the rest are set to display none. When a specific event is tri ...

Delivering styled coldfusion outcomes utilising css and jquery

After using jquery to retrieve some data, I've noticed that the results are displayed correctly but the CSS is not being applied. Is there a way to style the results with CSS? function doSearch() { //Making an AJAX call to the server $.ajax({ / ...

The CSS grid-template-area feature is not functioning properly in web browsers

Struggling with creating a responsive CSS grid layout for different screen sizes. I want to have five divs on desktop screens and adjust the layout for smaller screens. As a newbie in web development, I'm finding it challenging to get it right. .fir ...

Looking for some CSS to style the image below

Looking for CSS assistance to style the sample image provided below. The letter within the circular element is contained in a div while the subscript Z is represented by an image of a circle. https://i.sstatic.net/sKF1H.png .text-center { text-align: ...

Adjusting the alignment of table cell contents without the use of JavaScript or external CSS files is necessary

I need help creating a table that resembles the design shown in the image below. I want each td cell in the outer table to have a number at the top right with a border, and text at the bottom left without a border: https://i.sstatic.net/1YTkR.png Current ...

There seems to be an issue with the functionality of ComponentDidUpdate

Trying to use setState in the componentDidUpdate is causing an issue for me. I researched and found that adding a condition before using setState should prevent an infinite loop, but it didn't work as expected. Any suggestions on how to resolve this? ...

Don't forget to choose the right switch in your React multi-stage form!

I have successfully implemented a multi-stage form in react, which works perfectly with text fields. However, I recently encountered an issue when attempting to add a switch control to the form. The problem is that the switch selection is not retained when ...

Is it possible to adjust the range of a range slider based on the selection of a radio button or other input method?

I have a query and I’m hopeful you can assist: function UpdateTemperature() { var selectedGrade = $( "input[name='radios']:checked" ).val(); $( ".c_f" ).text(selectedGrade); var value1 = $("#tempMin").val(); var value2 = $("#tempM ...

Adding a simulated bottom border to a rotated container

Currently, I am utilizing the CSS3 rotate value to create an arrowhead effect for modal boxes. However, I now require a full arrowhead design with a bottom border. As this involves rotating a div at a 45° angle, adding another border to either side will n ...

Create a new project using Firebase Functions along with a Node.js backend and a React.js frontend

In the process of developing my application, I have chosen to utilize node.js, express.js, and Firebase with firebase functions, all coded in TypeScript. For the client side framework, I am interested in incorporating react.js. Currently, I have set up nod ...

Encountering an issue when trying to submit a post request: "Received an API resolution without a response for /api/comments, which could lead to delayed requests."

Hey, I recently started diving into Next.js and I'm facing an issue with making a POST request to the API. In my project structure, I have a comments folder nested inside the api folder. Within the comments folder, I've written the following cod ...

The :not selector in a chained condition is not functioning properly for a child div

I have a child div that is being impacted by the .img class. Even when I use the :not selector for this div like so .main .content .index-exp .img:not(.view-image){ /*rest*/ } it continues to affect my div. You can view the issue at this link. Is this ...

Troublesome Bootstrap Tooltip CSS not functioning properly with AJAX-loaded dynamic content

I'm experiencing an issue with bootstrap tooltips. The tooltips work in terms of functionality (showing on hover, positioning to the left, etc.), but they are not styled as expected. I have an AJAX request that fetches data and populates a table. Thi ...

What steps can I take to transform this jquery code into a react.js equivalent?

Can someone help me convert this jQuery code into ReactJS? I've been trying, but encountering a lot of errors. I'm new to jQuery and having trouble understanding it. In simple terms, this is how the code works: When I click on the text "Laptop, ...

Adding an exception for ClickAwayListener in React-MUI

Hey there! I'm currently exploring MUI and trying to incorporate the ClickAwayListener API into my project, but I'm facing some difficulties. You can take a look at my project on codesandbox here: https://codesandbox.io/s/react-leaflet-icon-ma ...

Accordion menu causing Javascript linking problem

After following a tutorial, I managed to create an accordion menu in JavaScript. In the current setup, each main li with the class "ToggleSubmenu" acts as a category that can hide/show the sub-lis. Now, my query is this: How can I retain the link functio ...