Skip to main content

New answers tagged

Advice
0 votes
0 replies
0 views

Radix UI, Slottable only works when it is a direct child of the Slot component

should i still raise it as a question?
Striker's user avatar
  • 11
3 votes
Accepted

setInterval() method and useEffect hook not working as intended when trying to update 'timer' state variable

You are overcomplicating things a bit with two timer/counter states and competing timeout/interval timers. Issues: As I pointed out in your post when it was still in the Staging Ground you've some ...
Drew Reese's user avatar
  • 208k
2 votes

setInterval() method and useEffect hook not working as intended when trying to update 'timer' state variable

The short answer here is that you're mixing vanilla JavaScript concepts with React concepts that don't work together like this. In particular, in the handleTimer function: setInterval(() => ...
brandonscript's user avatar
Advice
0 votes
0 replies
0 views

When to Use useState vs Redux for State Management in React

In my experience, the decision depends on the complexity and the amount of your data: Use useState (Component Composition): When you have a limited amount of data that is local to a specific area. ...
shirshamay's user avatar
Advice
0 votes
0 replies
0 views

Radix UI, Slottable only works when it is a direct child of the Slot component

Well i am not facing issue right now, i did have it earlier but then that feature was dropped. So it is just so that i know what to do when i face it again.
Striker's user avatar
  • 11
-1 votes

Production build crashes with "Cannot access 'lt' before initialization"; how to trace minified variable back to source

This is a Temporal Dead Zone (TDZ) bug that only appears in production because Rollup concatenates and hoists code differently than Vite's dev server. The variable lt is Rollup's minified name for one ...
Intruvurt's user avatar
Advice
0 votes
0 replies
0 views

Radix UI, Slottable only works when it is a direct child of the Slot component

Are you really just seeking advice, or do you want an answer to a clear programming problem you are facing? If the latter then I suggest you delete this post and re-post your question, this time ...
Drew Reese's user avatar
  • 208k
0 votes

TypeError: Cannot read property 'setGenericPasswordForOptions' of null

You’re getting this error because react-native-keychain isn’t available in Expo Go, so Keychain is coming back as null. That’s why it crashes on: Keychain.setGenericPassword(...) It’s not your token, ...
Ali Ahmed's user avatar
0 votes

GraphQL error: Expected type Int. Int cannot represent non-integer value

The returned values are always strings in html input fields, althought input fields with type="number" accepts only numeric values. Thus explicit conversion to number is needed to change ...
eigeS1R's user avatar
  • 148
0 votes

TypeError: Cannot read property 'setGenericPasswordForOptions' of null

Issue was due to stale React Native autolinking cache where react-native-keychain was missing from android/app/build/generated/autolinking/.../PackageList.java; I verified it via grep, cleared android/...
Negi Senpai's user avatar
3 votes
Accepted

Unexpected re-render despite no parent rerender and no change in props or state

As already mentioned, there's note in the React docs about that behavior: If the new value you provide is identical to the current state, as determined by an Object.is comparison, React will skip re-...
Michał Turczyn's user avatar
0 votes

Next.js server-side rendering

That error means the HTML rendered on the server is different from what React renders on the client, so hydration fails. It usually happens when you use things like "window", "document&...
KAMI's user avatar
  • 1
0 votes

Integrating noUiSlider.js with SurveyJS in a ReactJS project

SurveyJS has out of the box slider now. { "type": "slider", "name": "default-configuration", "title": "Default ...
Dmitry Kurmanov's user avatar
0 votes
Accepted

How to isolate isPending state from useActionState to prevent full form re-renders in React 19?

The performance bottleneck occurs because useActionState (and useFormStatus) are tied to the component's render cycle. If your hook is at the top level of a large form, any state change (like ...
Laurin F.'s user avatar
0 votes

React localhost:3000 refused to connect despite "Compiled successfully" on Windows 11

Alot of things could be wrong here for real. First, try killing the ports you have tried: npx kill-port 3000 npx kill-port 4000 Then restart. If the same issue, kill the port again with the above and ...
Anayo Samson Oleru's user avatar
0 votes

React native text going off my screen, refusing to wrap. What to do?

I tried most of the solutions here and even ask claude opus 4.6, none works for me. What fixed it for me was removing lineHeight from Text
Mark's user avatar
  • 78
Advice
0 votes
0 replies
0 views

When to Use useState vs Redux for State Management in React

How is your weekend? Use useState for simple, local component state that isn’t shared widely. Use Redux when state is global, shared across many components, or has complex update logic. Thanks
Tytanesk's user avatar
Best practices
1 vote
0 replies
0 views

Containers written as HOCs? (in the Container/Presentational pattern)

but then every time I look at a container, at the end it calls one specific presentation, which for me, seems to be limiting the reusability of the container. This is because the presentation ...
Drew Reese's user avatar
  • 208k
0 votes

how to include multiple code coverage's in the pipeline

I did this extension to answer this question: https://marketplace.visualstudio.com/items?itemName=ranouf.publish-html-tab You can use it like this: Single HTML file: steps: - task: PublishHtmlTab@1 ...
Cedric Arnould's user avatar
Advice
0 votes
0 replies
0 views

When to Use useState vs Redux for State Management in React

When you have an frontend you can have multiple scopes, for instance a global scope and local scope. Let’s imagine you have list of todos (global scope), you want to modify a todo, you create a local ...
antokhio's user avatar
  • 2,069
Advice
0 votes
0 replies
0 views

When to Use useState vs Redux for State Management in React

I advise you to look up an article by Dan Abramov (co-creator of Redux) called "You Might Not Need Redux " (PS. I am new to this format of discussion so I hope sharing article here is OK).
gmoniava's user avatar
  • 29k
Advice
0 votes
0 replies
0 views

When to Use useState vs Redux for State Management in React

For what it's worth this is not quite an apples-to-apples comparison. React state alone isn't a "state management system" whereas Redux is. I feel the Redux (React-Redux specifically) ...
Drew Reese's user avatar
  • 208k
2 votes

How to correctly reset form state and handle server errors using React 19 useActionState and useOptimistic

The trick you're missing is requestFormReset from react-dom — it was built exactly for this. Call it inside your action before the await, and it queues a reset that fires when the transition commits. ...
Shadi Sbaih's user avatar
-1 votes

Hide navbar and sidebar on 'login page', but show them on other pages

I was able to solve this, using useLocation(), App.jsx function App() { const location = useLocation(); return ( <> <div> {location.pathname != "/login" &...
Ikram Wani's user avatar
Best practices
0 votes
0 replies
0 views

Data Fetching in React

If the code for a particular component is growing to the point where it's difficult to maintain then, yes, it is generally considered a good practice to refactor that code into smaller components/...
David's user avatar
  • 221k
Best practices
0 votes
0 replies
0 views

How to track impressions on a post?

You already posted your learnings - just wanted to say the simple solution with a transparent pixel would work the same. You would request it on scrolling with a unique URI, after detecting it's in ...
Peter Pointer's user avatar
Best practices
1 vote
0 replies
0 views

How to track impressions on a post?

So I figured this out myself after some digging. Sharing here in case someone else runs into the same problem. The issue with tracking impressions on fetch is that it counts posts the user never ...
Farhan Asghar's user avatar
Advice
0 votes
0 replies
0 views

teach me how to build an leetcode clone

Thank you my friend suggested the same
Logeshwaran P's user avatar
Advice
0 votes
0 replies
0 views

teach me how to build an leetcode clone

Start with things you already know or feel comfortable with - and therefore use Node.js. That's totally fine.
pzaenger's user avatar
  • 12.1k
Advice
0 votes
0 replies
0 views

teach me how to build an leetcode clone

Thank you but i never heard of "bun" where should i learn it
Logeshwaran P's user avatar
0 votes

How do I use testing-library to fire React's animationEnd event with a value for animationName?

Testing library has a bug where it uses Object.assign to try to overwrite the animationName property, but the AnimationEvent.prototype has a readonly accessor, so Object.assign fails silently. You can ...
zzzzBov's user avatar
  • 180k
-1 votes

Tailwind CSS v4 arbitrary value classes (brackets []) not rendering in Next.js 16 with Turbopack

After extensive debugging, it appears to be an intermittent issue with how the Turbopack (Rust-based) compiler interacts with the Tailwind v4 JIT engine during incremental builds in Next.js 16.1.6. ...
Gonzalo Salas's user avatar
0 votes

Changing font family of all Material UI components

I am using Next.js 16 with MUI 7 and Tailwind 4. My setup is: AppStylesProvider - my wrapper around styles import { type ThemeOptions, ThemeProvider } from '@mui/material/styles' import { ...
Jiří Zeman's user avatar
0 votes

Error: Fast refresh only works when a file only exports components

For anyone who doesn't seem to be able to resolve the issue with above, please check the extension of your file. I had a component AddModel.tsx and a few types, labels, etc that were being used in ...
Urvashi Sharma's user avatar
0 votes

ReactJS: Autosave on fields within an accordion

If You just wanted to preserve MUI accordion state after closing and reopen add slot property <Accordion slotProps={{ transition: { unmountOnExit: false} }} >
Witold's user avatar
  • 108
2 votes

Vite build error: "useState is not exported by react/index.js" but works in dev mode

I literally ran into this exact same wall last week while setting up a new Vite project. It’s incredibly frustrating because everything works perfectly in npm run dev, and then the production build ...
Mikael Söderberg's user avatar
0 votes

Dynamic onClick and render in ReactJS

To let the blockClicked function know which block was clicked, you can wrap the function call in an ES6 arrow function inside the onClick handler. This allows you to pass specific arguments (like the ...
Grenish Rai's user avatar
0 votes

ReactJS API Data Fetching CORS error

I was learning React and encountered this problem while using a custom hook to fetch JSON data from a remote server. If you have a local development environment (localhost) like me, and you want to ...
Udochukwu Enwerem's user avatar
0 votes

How to getByRole a button with image in React Testing Library

The accepted answer is wrong, and I'm surprised more people have not pointed that out. The button already has an accessible name. The image's alt text becomes the accessible name. Thus, you could do: ...
Derek Henderson's user avatar
Advice
0 votes
0 replies
0 views

teach me how to build an leetcode clone

If you are trying to build and front-end back-end architecture, I would advise you to try using something such as next.js, it would allow you to have both API and frond end part on the same runtime. ...
adryan's user avatar
  • 1
Advice
0 votes
0 replies
0 views

I have to implement an test scenario for payment can anyone recommend the free tool or module

I don't think your questions are put very well here. However, if you look at payment vendors like adyen, they have plenty of docs that can help you out here: https://docs.adyen.com/development-...
Nathan Ormond's user avatar
Advice
0 votes
0 replies
0 views

I have to implement an test scenario for payment can anyone recommend the free tool or module

Before thinking at where to start, you have to learn how to ask more productive questions. This question is not focused enough. It looks like you simply have to learn the application field and testing ...
Sergey A Kryukov's user avatar
1 vote

How to ensure a React component has 'key' prop in TypeScript

You can do this using a Higher Order Component. It is a wrapper that takes your original component and injects an extra (mandatory) key prop. import React from 'react'; // wrapper that takes any ...
nullromo's user avatar
  • 2,787
1 vote
Accepted

Getting Floating UI to pin a popup on demand

The behavior you're seeing is autoUpdate doing what it was meant to do. keeping a "floating" element in sync with its "reference" element, even when you scroll. The main issue is ...
Skiller X's user avatar
0 votes

Jest: mocking console.error - tests fails

TypeScript Solution Based on @Mike's answer, here is a TypeScript-friendly approach: let consoleErrorMock: jest.SpyInstance; beforeAll(() => { consoleErrorMock = jest.spyOn(console, 'error')....
Jasperan's user avatar
  • 5,203
Best practices
0 votes
0 replies
0 views

How to track impressions on a post?

We are using infinite scroll for feed page, on page load suppose we are fetching 20 posts initially, impression for each post will need to be tracked only when user scroll down and post appears on a ...
Farhan Asghar's user avatar
Best practices
0 votes
0 replies
0 views

How to track impressions on a post?

They asked for "track impression only when it appear on the user screen" - that's what the transparent gif would be for. If the website appears on the screen, request that transparent png, ...
Peter Pointer's user avatar
Best practices
0 votes
0 replies
0 views

How to track impressions on a post?

I thought the OP explicitly asked for on-screen tracking, not fetches, though? So “search for one that works” is the summary?
Dave Newton's user avatar
Best practices
1 vote
0 replies
0 views

How to track impressions on a post?

I have done impression tracking with frontend & backend code I wrote myself. It is not worth the effort to code it yourself, unless you have a hard requirement to do so. If you are fine with a ...
Peter Pointer's user avatar
0 votes

How do I fix Blocked CORS with Firebase Hosting?

For 2nd Generation (v2) Functions For new or updated functions using the v2 SDK, you can set the cors option directly in the function definition: const { onRequest } = require("firebase-functions/...
Jorge Garcia's user avatar
  • 2,561

Top 50 recent answers are included