Having difficulty importing an scss file into a react component

I'm trying to implement a spinner as a React component, but I'm facing difficulties applying the SCSS file to it.

Here is a snippet of my loading.scss file:

$color: #e14eca;
$size: 12px;
$time: 1;

main {
   display: flex;
   justify-content: center;
   align-items: center;
   background: none;
}

.dank-ass-loader {
   display: flex;
   flex-direction: column;
   align-items: center;
   
   .row {
      display: flex;
   }
}

.arrow {
   width: 0; 
   height: 0;
   margin: 0 (-$size / 2);
   border-left: $size solid transparent;
   border-right: $size solid transparent;
   border-bottom: ($size * 1.8) solid $color;
   animation: blink $time + s infinite;
   filter: drop-shadow(0 0 ($size * 1.5) $color);
    
   &.down {
      transform: rotate(180deg);
   }
   
   @for $i from 1 through 18 {
      &.outer#{$i} {
         animation-delay: -($time / 18) * $i + s;
      }  
   }

   @for $i from 1 through 6 {
      &.inner#{$i} {
         animation-delay: -($time / 6) * $i + s;
      }  
   }  
}

And here is my React file:

import React from "react";
import styles from "loading.scss";



 const Spinner = () => {
      return (
        <>  <main>
        <div
          className="dank-ass-Spinner"
          style={{
            position: "fixed",
            display: "flex",
            flexDirection: "column",
            alignItems: "center",
            justifyContent: "center",
            top: "50%",
            right: "50%",
            left: "50%",
            zIndex: "99999",
            bottom: "50%"
          }}
        ><div className={styles.row} style={{ flexWrap: "nowrap" }}>
            <div
              className={[
                styles.arrow,
                styles.up,
                styles.outer,
                styles.outer18
              ].join(" ")}
            ></div>
            <div
              className={[
                styles.arrow,
                styles.down,
                styles.outer,
                styles.outer17
              ].join(" ")}
            ></div>
            <div
              className={[
                styles.arrow,
                styles.up,
                styles.outer,
                styles.outer16
              ].join(" ")}
            ></div>
            <div
              className={[
                styles.arrow,
                styles.down,
                styles.outer,
                styles.outer15
              ].join(" ")}
            ></div>
            <div
              className={[
                styles.arrow,
                styles.up,
                styles.outer,
                styles.outer14
              ].join(" ")}
            ></div>
....(remaining content is similar to the original text)

Any idea why I'm only seeing a bunch of empty class divs instead of the spinner animation in my React component?

Answer №1

To organize your project, consider creating a new folder and relocating your JS and SCSS files into it.

Then, proceed to import them using the following line of code:

import './style.scss'

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

Sending arguments to a JavaScript function together with a callback

I have a link on my HTML page that looks like this: <a id="save_report" href="javascript:void(0);" title="Save Report" onclick="javascript:enterReportNameToSave(<?php echo $upload_count?>,<?php echo $startOffset;?>,<?php echo $affiliateI ...

Console.log is not visible to jQuery's getJSON function

Currently, I am utilizing the getJSON method as shown below: $.getJSON("js/production-data.json").done(function(response) { console.log(response); console.log('hello'); }); While monitoring Firebug, the data retrieval process seems to ...

How can I restrict the navigation buttons in FullCalendar to only allow viewing the current month and the next one?

I recently downloaded the FullCalendar plugin from Is there a way to disable the previous button so that only the current month is visible? Also, how can I limit the next button so that only one upcoming month is shown? In my header, I included this code ...

What is the best way to comprehend IE comments in a given condition?

I recently came across some conditional comments in a theme I'm working on that dynamically add classes to the html tag depending on the version of Internet Explorer being used. <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" ...

What causes duplicate packages to appear in Bower at times?

There appears to be two identical packages available for the Sugar javascript library, sugar and sugarjs. Are these packages interchangeable or are they being maintained separately by different individuals? ➔ bower info sugarjs bower sugarjs#* ...

An approach to transferring the ID of a multiple dropdown within the $.each function

function filterFields(classname, value, chkClass) { var checkedfields = []; $.each($("."+classname+" option:selected"), function(){ checkedfields.push($(this).val()); }); $('#'+chkClass+'Filters').val(ch ...

In Stripe.js, the background color and height of the credit card input cannot be customized

I'm struggling with customizing the appearance of a Stripe credit card input within my Vue.js application. I want to adjust the background color to #f1f1f1 and set the height to 60px, but despite trying both base styles and css, I can't seem to g ...

When trying to use preact as an alias for react, the error "Module not found: 'react/jsx-runtime'" is thrown

Avoid using the outdated guide I linked; follow the one provided in the answer instead I am trying to transition from react to preact by following their migration guide. I updated my webpack.config.js to include: alias: { "react": "pr ...

Updating the color of a radio button in material-ui

import { createMuiTheme, ThemeProvider } from "@material-ui/core"; const theme = createMuiTheme({ palette: { primary: { main: "#5E9C60", }, }, }); const RadioButton = ({ category, handlerForCategory ...

IE rendering issue: jQuery image slideshow captions lack transparency

I recently created a slideshow using jQuery that features fading images with corresponding captions in individual divs. While the captions are meant to have a transparent appearance, I have encountered an issue specifically in Internet Explorer where this ...

Tips for resolving a flickering issue that occurs when switching to an input field with our default value / placeholder plugin

In the realm of web development, numerous plugins cater to the implementation of HTML5's placeholder attribute in older browsers. The plugin we have opted for can be found here. Unlike some other alternatives, this particular plugin, with a few modif ...

Updated Multer version causing issues with uploading image files

After using multer middleware to upload an image, I encountered an issue where the file image was showing up as undefined. This meant that I couldn't retrieve the name or file extension of the uploaded file. I'm not sure if this is an error with ...

a container holding two floating divs

I have been attempting to create two divs positioned side by side, with one containing content and the other acting as a sidebar. Both of these divs are contained within another larger container div. Despite my efforts, I have not been successful in achiev ...

Having trouble with Material UI ListItem and setting a custom key prop

While using Material UI for React, I encountered an issue when attempting to pass a key prop to a ListItem: A warning popped up stating that key is not a valid prop. Trying to access it results in undefined. If the same value is needed within the child ...

Show the value of an array index in JavaScript

Imagine retrieving data from a local API using the code snippet below: {console.log("Bin", this.state.rows.filter(qc => qc.BinsByDayByOrchardsQCs.length > 0).map((bin) => bin))} The output you get may look something like this: 0: {…} ...

Conceal and reveal elements using a specific identifier with

Web Development Guide <ul id="menüü"> <li id="meist"> <p><a href="meist.html">Meist</a></p> </li> </ul> <div id="submenu"> <ul id="submeist"> ...

An error occurred with redirecting using jQuery Mobile's new method in version 1.5

Utilizing jQuery Mobile for its history state feature, I am looking to redirect users to another "page" using the jQuery method recommended in their latest documentation. p/s: I prefer the jQuery navigation method due to the hashchange/history support and ...

Client-side sorting in jqGrid

I'm working with a tree-grid that has autoloading rows. My objective is to sort the grid by the tree column directly on the client side. However, every time I click on the column header to sort, it triggers an unnecessary Ajax call for sorting, when ...

Struggling to properly render JSON data

Having trouble accessing specific elements in a script that merges local JSON files using AJAX? The script works fine in Chrome Console, but you can't reach certain elements like 'object.country'. Any suggestions on how to tackle this issue? ...

Using jQuery to organize divs into columns

I am working with a parent div that contains 19 child divs all with the same class, structured like this: <div id="dropdown-content1"> <div class="CatsColumn"></div> <div class="CatsColumn"></div> <div class="C ...