Skip to main content

All Questions

0 votes
0 answers
30 views

Trouble Testing Error Handling in Next.js Component with TypeScript and Vitest

Environment: "next": "14.2.3", "vitest": "1.6.0", "@testing-library/jest-dom": "6.4.5", I'm trying to write tests for a Next.js component ...
pop's user avatar
  • 109
0 votes
0 answers
79 views

How to style mui switch track thumb and change it's position?

i'm trying to style my switch from material UI to look like this enter image description here and right now it looks like this: enter image description here as I see from inspect I need to change this ...
Basma Tayeh's user avatar
0 votes
1 answer
237 views

MUI custom switch (IOSSwitch) sliding animation does not work when add onChange event

Update: I have fixed the issue. The problem was occurring for having two versions of material UI. I have removed the material UI core v4. Now it works fine. I am using the from Material UI. ...
Nayeem M. Muzahid's user avatar
-1 votes
2 answers
148 views

Hi, Every time when I use react router dom in my react app it got stuck [closed]

Every time when I use react router dom in my react app it get stucks on switch export ERROR in ./src/App.js 19:39-45 export 'Switch' (imported as 'Switch') was not found in 'react-router-dom' (...
Ahad Dev's user avatar
0 votes
2 answers
92 views

Javascript, React Ref and Switch (Looking for a better solution)

I have the following code that uses multiple useRef() hooks and a switch statement to scroll to a specific ref based on an index value: const ref0 = useRef(); const ref1 = useRef(); const ref2 = ...
Amin Noura's user avatar
1 vote
0 answers
222 views

How do I conditionally render <h2>{title}</>?

I have three React components: Card, ItemForm, ItemDetails. I've tried countless different ways of rendering and conditionally rendering the <h2>{title}</h2> in the Card. I want to change ...
Julian Jernigan's user avatar
0 votes
1 answer
289 views

switch statement in a reducer function

I've been at a lost with this problem for over 2 hours. I've tried so many things. Here is the question: Write a switch statement for the provided reducer function such that when it is used to reduce ...
aw_codes's user avatar
1 vote
1 answer
215 views

Alternative way to dynamically render React components coming from an API

I'm building a website with Next.js/React that is consuming content from Strapi CMS. I want to keep a page template for a news article as flexible as possible, so content editors so they can choose ...
jonnow's user avatar
  • 858
0 votes
1 answer
71 views

Switch statement behaving differently on Vercel and in local. Using React.Js

Hello everyone and thank you for your time, On the first render of the App in Vercel the "sortBy" isn't applied. When selecting different options from the dropdown that controls the state ...
Rados Rosic's user avatar
0 votes
0 answers
110 views

Does too many switch statements lower performance?

I'm learning React and am trying to make a component that displays an image dependent on props (game) passed through it. So far I'm using a switch statement that changes the source of the image, but I'...
Akio's user avatar
  • 1
1 vote
1 answer
33 views

Display different components depending on props: TypeError

I am currently trying to create a type safe implementation of an component that takes its props and displays different components depending on its props. I have tried a number of different approaches ...
nico95's user avatar
  • 11
0 votes
1 answer
60 views

How to add another prop to my Switch statement in React app

I have a React component based on a type prop I am returning jsx. type Props = { variant: 'type-one' | 'type-two' | 'type-three'; show: boolean; }; const Placeholder = ({ type, show }: Props) =&...
meez's user avatar
  • 4,530
1 vote
1 answer
416 views

How do I use React Router Dom to navigate to a new page as a result of a Switch Case?

Essentially when a form is submitted I want the page to navigate to a different page as a result from a switch statement. switch (real_input_value()) { case 'Help': console.log('Displaying list ...
ewakwwg12's user avatar
0 votes
1 answer
190 views

React - Conditional Rendering with Switch and boolean case

I would like to clarify a doubt on React Conditional Rendering with Switch Case I have an implementation with conditions. ie I have to set a string value based on boolean case For example let str = &...
Manushi's user avatar
  • 759
0 votes
1 answer
33 views

call a imported component in function with React js

I imported Login component and trying to use in switch case as per the condition, I'm not getting expected result import * as React from 'react'; import Login from './login'; function classListR() { ...
Mr. Mreetunjay Messi's user avatar

15 30 50 per page
1
2 3 4 5
10