NextJS compilation sometimes results in undefined errors when using Sass styles

My peace lies in the sass code:

.link
  display: inline-table
  text-align: center
  align-self: center
  margin: 5px 15px
  font-size: 20px
  color: black
  text-decoration: none
  transition: 0.1s ease-in-out

.link:hover
  text-decoration: underline

.link-red:hover
  text-decoration: underline
  color: $color-red

And tranquility can be found in the index.tsx code:

<div>
   <a href={link} className={styles.link + " " + styles.linkRed}>{linktext}</a>
</div>

Once compiled, the resulting html is as follows:

<div>
   <a href="/auth/login" class="links_link__31hqZ undefined">Login</a>
</div>

While style link was successfully compiled and attached, the second one ended up as undefined.

What caused style link-red to become undefined?

Answer №1

It seems like you are facing an issue because of the difference between styles.linkRed and link-red in your CSS. To resolve this, you should use styles['link-red'] in your JSX.

As of now, Next.js does not support automatic conversion to camelCase. However, you can refer to this discussion for more information on this topic.

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

There seems to be an issue with the Next.js build as it encountered errors while exporting on

I encounter this error during the build process. info - Generating static pages (15/15) > Build error occurred Error: Export encountered errors on following paths: /routine/RoutineLists at /home/corepen/Desktop/Project 1/rouDDine-client/no ...

Increase the height of an element based on the content of the text within

Today I am facing a challenge: I need the text below to change when I click on one of these icons: Luckily, it works with the following code: CSS .games-text { background-color: $color-primary; & p { max-width: 90rem; text-a ...

react-navigation hook for navigating

Currently, I am utilizing the react-navigation hook and instead of repeating the hook in various components, my goal is to pass navigation as a prop. const navigation = useNavigation(); ... <MyButton resetLocation={resetLocation} navigation= ...

Jquery scroll animation not reaching the intended position when scrolling upwards

While developing a new feature for my music player, I encountered an issue with centering the track/div upon clicking in the scrollable parent div. Sometimes it doesn't scroll to the center as intended and instead scrolls erratically to the top of the ...

Unable to display results in React Native due to FlatList not being shown

I'm a beginner to React Native and I'm attempting to create a simple flatlist populated from an API at , but unfortunately, no results are displaying. Here's my App.tsx code: import React from 'react'; import type {PropsWithChildre ...

The background image is not displaying properly within a <span> tag

I am attempting to show a smiley icon within a span tag that is nested inside a list item. Below is the code snippet: <p> It contains various tabs:{" "} <li> Home - Showcase and brief informati ...

React router loader is not functioning correctly when trying to fetch data

My attempt to fetch an array of data from an API is resulting in an empty response within the application. However, when I try the same call in a swagger, it returns the correct array. HomePage.tsx: const HomePage = () => { const books = useLoaderDat ...

A guide to creating a personalized horizontal dashed separator in Material UI

I'm looking to customize a divider template by turning it into a horizontal dashed divider, but I'm struggling to override it. Even when attempting an sx edit with a borderRadius, the divider doesn't change as expected. source code: import ...

Setting various font sizes for a single element

I'm looking to enhance my text by incorporating an embedded font in addition to Arial as a backup option. However, the embedded font requires a larger font size compared to Arial. Is there a way to ensure that when displaying the same text element, A ...

Issues with hidden overflow and height attributes not functioning correctly in Internet Explorer 9 when using the DOCTYPE HTML standards mode

I have a <div> with overflow:hidden and height:100% that adjusts the div contents to fit the window's height on Chrome and Safari. However, in IE9, the div does not respect the styles of overflow:hidden and height:100%, causing it to expand to ...

Aligning Text to the Right Using CSS

HTML <body> <div class="menu_items"> <h1>My Heading</h1> <nav> <a>Item 1</a> <a>Item 2</a> <a>Item 3</a ...

Storing information from a form into a database with the help of TypeORM on Angular 6

Utilizing TypeORM alongside Angular to store form data in the database has been successful. The connection configuration is correct, allowing for data storage from the backend. { "type": "mssql", "host": "***", ...

Creating an array with varying types for the first element and remaining elements

Trying to properly define an array structure like this: type HeadItem = { type: "Head" } type RestItem = { type: "Rest" } const myArray = [{ type: "Head" }, { type: "Rest" }, { type: "Rest" }] The number of rest elements can vary, but the first element ...

Wordpress is having issues running jQuery

I've developed a function inside js/custom.js. The purpose of this function is to arrange posts in my Wordpress site by applying a class called articleAlign. This class will enhance the spacing between the article title and its excerpt, but only when ...

What is the process for removing a particular file from my bundle?

I am currently utilizing webpack to build my angular2/typescript application and have successfully generated two files, one for my code and another for vendors. However, I am in need of a third file to separate my config (specifically for API_ENDPOINT) whi ...

determine function output based on input type

Here's a question that is somewhat similar to TypeScript function return type based on input parameter, but with a twist involving promises. The scenario is as follows: if the input is a string, then the method returns a PlaylistEntity, otherwise it ...

Directly within Angular, map the JSON data to an object for easy assignment

I came across this information on https://angular.io/guide/http. According to the source, in order to access properties defined in an interface, it is necessary to convert the plain object obtained from JSON into the required response type. To access pr ...

Is there a way to replicate the tree structure of an array of objects into a different one while modifying the copied attributes?

Is there a way to replicate the tree structure of an array of objects to another one in TypeScript, with different or fewer attributes on the cloned version? Here's an example: [ { "name":"root_1", "extradata&qu ...

Refresh needed for Material UI styles to load correctly in Next JS

UPDATE: Reproducible issue https://github.com/ganavol409/next-material-ui-classes-bug Issue seems to be related to Higher Order Components and importing useStyles from Material UI Implemented Solution: https://github.com/mui-org/material-ui/blob/master/ ...