All Questions
4,318 questions
0
votes
1
answer
24
views
shadcn chart has no space between label and value
The issue I'm facing can be seen on the image, essentially some bigger values don't have any padding in between value and label, I'd like to know how I can make it at least 2px
Image:
Part of code:
...
0
votes
4
answers
80
views
Render a list of jsx components in react [closed]
I have a list, containing some jsx components like components:
components = [
<span className="c1 c2" onClick={() => console.log("test")}>...</span>,
<span ...
0
votes
1
answer
45
views
conditionally add prop to a jsx element [duplicate]
I have a react app and am trying to pass down a prop to a jsx element based on a condition. The element in question is an anchor tag and if the condition is true I would like to pass a rel="...
1
vote
2
answers
38
views
Error while styling background color of an span in React
I'm following Jonas Schmedtmann's full-stack crash course, and everything is fine. But in this part, I'm receiving a React runtime error (TypeError: Cannot read properties of undefined (reading 'color'...
0
votes
0
answers
24
views
React/JSX-runtime Module not found
Currently working with a React project 17 and after adding the React-Timezone-Select package I've got a build error saying the following :
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\...
1
vote
1
answer
91
views
How do I calculate the color RGB code in a color picker?
I'm trying to make a reusable color color picker component in react, I want to calculate the RGB color code using the mouse coordinates on a 256 by 256 div, the div has a white background color and it ...
0
votes
1
answer
88
views
Can we use React Hooks inside JSX component's callback like this?
Does this count as breaking the rule of hooks? It doesn't show the error/warning 'Error: Invalid hook call' and the code works normally. useEffect also mounts only once
1.✅ Call them at the top level ...
1
vote
1
answer
56
views
How to pass a React component to a component and use it inside the component as a component?
I have a Button component that allows some props like variant, active, size etc. to change its styling.
What I want is, passing the Button component to another component and use it there as a normal ...
1
vote
1
answer
46
views
Force ReactJS routes index to reevaluate before redirecting on login
I wish to conditionally include authenticated routes on the routing index of my ReactJS application based on whether a token exists in the user's local storage. However, for this to work, the routes ...
1
vote
1
answer
48
views
Switch component is not working after switching from Checkbox
I was using Ant Design Checkbox earlier to check and publish the comments and it was working fine with no errors.
<Checkbox
key={record.id}
checked={Publish[record?.id]?.["ispublish"] ...
1
vote
1
answer
127
views
TypeError: Cannot read properties of null (reading 'useContext') - Material UI
I'm using MUI(Material UI) in my project.
Component that I'm trying to use is Button.
Check its official component docs here.
Code in which error is occuring :
import * as React from 'react';
import ...
0
votes
2
answers
48
views
React Component Collapsing Issue: Ref Not Initialized During URL Parsing
I have a component that should expand if it is selected. Here's my current approach:
<Element
ref={elementRef}
style={{ height: isSelected ? `${elementRef.current.scrollHeight}px` : '0px' }} ...
-1
votes
1
answer
34
views
Runtime Error with react-data-table-component in React Application
I encountered a runtime error while trying to integrate react-data-table-component into my React application. The error seems to occur when I attempt to render the data table after fetching data from ...
1
vote
1
answer
54
views
In React, does creating a click handler outside the JSX have any improvement on performance?
Here is an example of 2 buttons with click handlers, one function is created in the component body, the other in the JSX. Is there any performance differences?
function Parent() {
const [count, ...
1
vote
1
answer
73
views
Call custom hook only on the active component in the DOM
My goal is to detect a click outside of the components using this custom hook:
const useOutsideClick = (callback) => {
const reference = useRef();
useEffect(() => {
const handleClick = (...
1
vote
3
answers
62
views
Optimistic rendering to show votes
At the moment the votes {count} is not showing up on mount. I'm using useEffect to get the article and useState to set the count to article.votes. The votes go up after clicking the button twice as ...
-3
votes
3
answers
73
views
What is the simplest possible way to get a div button to hide its parent div on click in React.js [closed]
I have a task that is simple (one line) in plain HTML/CSS/JS, but I can't find a simple and working method in React.
I have a parent div, and it has two children. The second child is the meaningful ...
0
votes
0
answers
12
views
Error in a script for Adobe Illustrator in charge of numbering
I’m working on a JavaScript script for Adobe Illustrator that will number multiple text fields in an.ai. The script should increment the numbering in multiple text fields at the same time and generate ...
-4
votes
1
answer
88
views
React app still stuck on loading page despite having an active session on my local Keycloak server [closed]
I am developing a react app locally and using Keycloak to manage authentication. I used the keycloak.js package and the react-keycloak package to access the Keycloak server from the react app.
When ...
1
vote
1
answer
52
views
Why component state is empty after dispatch redux action?
I am trying to implement the product list & search feature with debounce, but SearchProducts component's state search is empty after the dispatch action in the ProductList component. Can someone ...
1
vote
1
answer
66
views
Data-driven fields in React form [duplicate]
I'm building a form in React to support user input for CRUD operations. I'm looking to make the fields shown in the form data-driven from an array with a view to eventually be able to read them from a ...
-1
votes
1
answer
25
views
Why is my dynamically generated HTML content not appearing in the React component? [duplicate]
I'm building a React application where I need to insert some HTML content dynamically based on user interactions. Here's a simplified version of what I'm trying to do:
import React, { useState } from '...
0
votes
1
answer
49
views
React state showing weird behavior
I am new to react and making a simple shopping cart for a coffee shop. whenever i add a item to cart if the item is not already in cart then i basically add it in with the rest of the items and set ...
0
votes
1
answer
59
views
Prop is not giving effect
This is my react component
const ButtonComponent = ({ children, onClick, disabled, className = "" }) => {
console.log("class name is ", className);
const buttonClassName = ...
0
votes
0
answers
20
views
React useEffect() not executing before page render [duplicate]
I'm trying to pull postcode information and display it on my react app. The code so far looks as such:
const UKPar = () => {
postcode = "SW1A2AA"
const [ukPostcodeData, ...
0
votes
1
answer
36
views
How can I pass the value between tag to the child component? react jsx
I have jsx like this,
import TableCell from '@mui/material/TableCell';
import TableCell from '@mui/material/TableRow';
<TableRow>
<TableCell sx={{minWidth:45,width:45,maxWidth:45,...
1
vote
2
answers
68
views
How to change the Page in React.js
I'm learning React.js and I'm creating a demo.
I have created a Login page. Now I want to develop the functionality that if I'm using admin's credentials then I should change the current page layout ...
1
vote
1
answer
72
views
React's useState hook defined inside function component in TypeScript still gave error - Invalid hook call
I was building a custom react component library. When I started using useState hook for a hover feature implementation. I started getting the following error in the browser console from the app ...
1
vote
1
answer
59
views
How to pass modular styles through props in React?
I have a component:
import React from 'react';
import s from './SectionsTitle.module.css';
const SectionsTitle = (props) => {
return (
<div className={props.styleTitle}>
{props....
1
vote
2
answers
77
views
Ensure that Promise has been resolved before rendering view
What specific syntax needs to be changed in the code below in order for the value returned by the currentSession() function to correctly set the html that is rendered to the user in the web browser?
...
0
votes
0
answers
24
views
Lightningchart JS - Chart is not interactable
I have 5 different line charts being rendered in my React app. Below is one of the methods to create those charts.
function createEcgHeartRateChart(
response: any,
startInterval: string,
...
0
votes
0
answers
29
views
Change site name [duplicate]
I can’t change the site name, I tried adding a tag
<meta property="og:site_name" content="sitename">
tried schema.org
<head>
<script type="...
0
votes
1
answer
277
views
NextJS App Router: How to access child component properties in layout?
To make use of the layout feature in the NextJS's App Router, I want to dynamically update the page title (<h1> tag, not metadata like <title>) on the layout depends on what the page ...
0
votes
1
answer
31
views
React app 'Encountered two children with the same key, `thumb-undefined`'
I'm trying to create a time slider in my react app and I can't beat this error below that keeps showing up in my browser console.
bundle.js:21658 Warning: Encountered two children with the same key, `...
0
votes
1
answer
80
views
Showing intersection of a plane in a 3d shape with Three.js
I tried to animate with Three.js to show the intersection plane on a 3d object. In this example, I have used a cone as an example for the 3d object in the following code:
import React, { useRef, ...
0
votes
1
answer
46
views
Using an external function to fetch data in NextJS
I'm trying to limit repeated code by moving the code that fetches data to an external file.
The fetchUserInfo I'm using uses the useEffect, useState hooks and as such needs to be a "use client&...
0
votes
1
answer
37
views
React - component content not pulling through
I'll admit I'm relatively new to React but I'm simply trying to pull through content from a Child component to the parent App component but it's not pulling in the content and I can't figure out why.
...
0
votes
0
answers
31
views
Styling block diagrams in the react-simple-flowchart library
Good day. When developing the project, I faced the task of creating a diagram, for this the react-simple-flowchart library was used. Now the task is to stylize the elements of the block, that is, you ...
0
votes
1
answer
77
views
Custom typography theme not able to override the default typography in MUI in Next js
I'm using Material-UI (MUI) with a custom theme in my Next.js React project. While colors from the theme are applied correctly, I'm unable to change the default font sizes of H2 and H5 elements. I've ...
0
votes
0
answers
20
views
How to restrict Emmet suggestions to only JSX code in `javascriptreact` files in VS Code?
I'm using Visual Studio Code for React development and I want Emmet suggestions to appear only when I'm writing JSX code, not regular JavaScript, in javascriptreact files (.js, .ts, .jsx or .tsx).
...
1
vote
2
answers
56
views
How to Minimize Code Duplication in React (For Loop Problem)
I want to create multiple Profile Cards in my React app, but I'm currently using repetitive code, which doesn't seem efficient. I tried using a for loop, but it didn't work as expected. How can I use ...
0
votes
2
answers
56
views
I want to implement a feature where it is like a background fade on scroll
I have tried literally everything I can search for and think of but nothing is letting me implement this feature. I want the background to have completely faded to black by the time the "who"...
0
votes
1
answer
206
views
Cannot override CSS module style with style in global (or external) stylesheet in React / Next.js / React Native
I'm struggling to find a solution to this simple problem. I have a component which I, by default, style using a class from a *.module.css file. However, I want to override this style with one from a ...
0
votes
1
answer
39
views
The div wont take the box shadow style in ReactJS
i have a div that has box shadow
<div
className="text-white"
style={{
boxShadow: `0px 131px 64px -44px ${brightestColor} rgba(0, 0, 0, 0.75)...
0
votes
0
answers
246
views
Module not found: Can't resolve 'devlop' in '...\node_modules\hast-util-to-jsx-runtime\lib'
I'm trying to build a web chat app with React and getStream.io, and I get the error message in the title when I try to run npm start. This is after running $env:NODE_OPTIONS="--openssl-legacy-...
0
votes
1
answer
253
views
What is giving me a blank page on a React app on LocalHost?
I created a react page (localhost) to follow along with a tutorial, but my webpage is completely blank. The console shows the attached error messageenter image description here
I added
“permissions”: [...
-1
votes
1
answer
287
views
Issues with reading files off of the filesystem in vercel
So, I've been making a website, which has a "blog" in it, consisting of a few markdown files, which I just read off of the file system. Said read works perfectly with 0 errors everywhere on ...
0
votes
1
answer
150
views
Terminal error: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined
I try to make an Navigation bar, when i run npm dev its rendered perfectly but the console says:
Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (...
-1
votes
1
answer
84
views
Is it possible to create a reusable function in Reactjs
I would like to create a reusable function in a standalone JavaScript file that I could use to send two parameters in the form of a json to an API, using the GET method, which would return a json file ...
0
votes
1
answer
176
views
Custom MUI fields (<TextField />) not recognizing a change in value
I'm trying to create custom form components so I don't need to update every item if I decide on a style change.The ReportSelect version does not update the value upon selection of a menu item, and the ...