Experiencing problems with CSS compatibility while transitioning from vanilla JavaScript to React

Currently, I am working on revamping the frontend of an app that was initially built with vanilla javascript and transitioning it to a React framework. However, I'm encountering some challenges with styling the HTML elements. Specifically, the textarea at the bottom is not the right size, and the buttons at the bottom are misaligned and incorrect in size. After changing all "class" attributes to "className" for JSX compatibility, I've been unable to resolve these issues despite checking for typos or differences in JSX attributes.

This page is displayed as a 400 x 500 electron window. It functions perfectly when loading the original HTML file.

Update 5/3/2021 @ 3:43 PM EST Upon further inspection of my JSX file, I discovered that the textarea does not accept the entered values for rows and cols attributes. Additionally, the submit button (id="submit_button") does not apply any CSS from the buttons class, while the cancel button does.

Original HTML File


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title>Feedback</title>
            <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
            <link rel="stylesheet" href="./styles/feedback.css"/>
            <script defer src="../src/feedback.js"></script>
        </head>
        ...
... (original JS, JSX, and CSS files follow, with slight variations from the previous versions)

Answer №1

As a newcomer to React, I encountered an unexpected issue with CSS files affecting my current page design. It turns out that styles from another page's CSS file were interfering with the layout of pages I was working on.

I had created a separate page named "issue_reporter" with its own CSS file containing styling for all textareas. This caused unintended effects on other pages utilizing textareas, even though I had not imported this CSS file to those specific pages.

To address this issue, I modified the styling in the "issue_reporter" CSS file to only target its specific id rather than applying styles globally to all text areas. I also made similar adjustments for buttons.

Before the changes, the CSS code in issue_reporter.css looked like this:


**textarea** {
    // styling properties
}

After making updates, it now appears as follows:

**#issue_step** {
    // styling properties
}

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

Although PhoneGap resolution remains consistent, the outcomes may vary

I seem to be facing a similar issue as discussed in this post on Stack Overflow: Screen Resolution On A PhoneGap App My problem is that I have both an iPad and an Android tablet, both with a resolution of 1024 pixels across. However, while my screen displ ...

"Maximizing the Potential of refetchQueries in reason-apollo: A Comprehensive Guide

Encountering issues setting up refetchQueries with reason-apollo. Following a setup similar to the swapi example here, I have a listing and a form for adding new items via a mutation. Upon successful mutation, the goal is to refetch the items in the listin ...

Error: Null value detected while trying to access the property 'appendChild'

Can anyone help me with this error? Uncaught TypeError: Cannot read property 'appendChild' of null myRequest.onreadystatechange @ script.js:20 Here's the code snippet where I'm facing the issue // index.html <html> <he ...

Validating a form using ReactJS can be a bit time-consuming as it involves

Having an issue with React validation on a login form. When I click submit after entering the correct email and password, it returns false initially but changes to true only after the third attempt. Why does the formValid state take time to update? How can ...

Using local variables in NodeJS callbacks

Despite the abundance of information on SO, I have yet to find a suitable answer to my particular situation. The following code snippet is causing me issues: for(var i=0; i < shop.collections.length; i++){ if(!shop.collection[i].active){ var dat ...

Tips for leveraging stage 3 functionalities in TypeScript?

Array.prototype.at() is currently in the proposal stage 3. Even after adding "lib": ["ESNext"] to my tsconfig.json, I encountered the error: Property 'at' does not exist on type 'number[]'. Could you shed some light ...

Verify whether a component is a React.ReactElement<any> instance within a child mapping operation

I am facing a challenge with a component that loops through children and wraps them in a div. I want to exclude certain elements from this process, but I am struggling to determine if the child is a ReactElement or not (React.ReactChild can be a string or ...

Embracing PWAs with subdomains – seamless installation

One of my Progressive Web Applications (PWA) called app A contains a link to another app, app B. Initially, I hosted both apps on the same subdomain (for example: ) and everything worked perfectly - installing app A also installed app B. However, when I a ...

Generate a variety of HTML ordered lists

Can anyone assist me in determining the type of ordered list shown below? What is the method to achieve an ordered list like this: (a) (b) (c) in HTML? ...

The JSON request was unsuccessful in sending the JSON object to PHP, resulting in an empty var_dump

I am encountering an issue where my $_POST array in PHP is empty when I try to pass a JSON object with an AJAX request on my JavaScript page. Here is the JavaScript code: function send(cat, subcat) { var type = cat.options[cat.selectedIndex].text ...

Is there a way to consistently trigger the browser.webRequest.onBeforeRequest event in Mozilla Firefox when it is launched via a link?

Hello knowledgeable individuals. I am unable to solve this issue on my own. Here is the add-on I have created: 1) manifest.json: { "manifest_version": 2, "name": "Example", "version": "1.0", "description": "Example", "permissions": [ "tabs" ...

Reset the input field once the message has been successfully sent

My goal is to clear the form message input field after the form is sent. However, it seems to be clearing the data before it has a chance to be sent. Here is the code I'm using: <script> $(function () { $('form#SendForm'). ...

Backdrop behind Material-UI Drawer Component

Struggling with implementing the semi-transparent background overlay for the open side menu in a React application using material-ui. Any suggestions on how to achieve this? http://www.material-ui.com/#/components/drawer ...

Having difficulty with uploading images in the correct size on the AWS S3 server

When I upload an image to AWS S3 bucket, the image size is only showing as 6 Byte, which is not the actual size of the image. I am confused why the image is not uploading with its actual size. What could be causing this issue? interest.js file Inter ...

Creating tailored output data from a single table

Can you please assist me with a problem I am facing in generating output data using PHP and MySQL? Below is an image of my table: https://i.stack.imgur.com/zaieZ.png I would like the output to be displayed to the user in the following format: 1. Account ...

What is the best way to make a black background div that perfectly aligns with another div?

When hovering over an image, I want it to fade out to opacity: 0.4, but instead of fading to white, I would like it to fade to black. To achieve this, I decided to change the background color of the body to black so that the fadeout will be towards black. ...

Stop objects from shifting while easily applying a border

I have a code that adds a red border around elements when you mouseover them and removes it when you mouseout. However, the elements jump around when the border is added because it changes their dimensions. Is there a way to stop this jumping behavior? ...

Why is the type of parameter 1 not an 'HTMLFormElement', causing the failure to construct 'FormData'?

When I try to execute the code, I encounter a JavaScript error. My objective is to store the data from the form. Error Message TypeError: Failed to create 'FormData': argument 1 is not an instance of 'HTMLFormElement'. The issue arise ...

Can Child Component Changes in React Checkbox Cause Parent Node to Re-Renders?

Struggling with creating checkboxes for my project, I've spent an entire day on it without finding a solution. The issue involves a main checkbox that controls all child checkboxes. The desired functionality is to have the parent node's "allChec ...

Improve the way you manage the active selection of a button

ts isDayClicked: { [key: number]: boolean } = {}; constructor() { } setSelectedDay(day: string, index: number): void { switch (index) { case 0: this.isDayClicked[0] = true; this.isDayClicked[1] = false; this.isDay ...