Skip to main content
Filter by
Sorted by
Tagged with
-6 votes
0 answers
105 views

I have a particular situation where I need a component (ViewOne) to update a ref, and read from that ref on mount. I also have a second component (ViewTwo) that needs to render different content ...
chrisroode's user avatar
2 votes
1 answer
65 views

i’m building a small AI chat ui in react (next.js app router, react 18) that streams tokens from my backend (openai style stream). basic flow: user types a prompt i push the user message into ...
Eli's user avatar
  • 57
Best practices
0 votes
3 replies
72 views

I am planning to implement pagination into my project for my data from Supabase, I had the idea that since there are different parameters (such as search text, page number, filter) that I should use ...
1million_ naira's user avatar
-3 votes
0 answers
36 views

const onChangeFn = (e,i) => { const data = e.target.value; if(/^\d?$/.test(data)){ let new_Array = [...values] new_Array[i] = data; setValues(...
nikhil singh's user avatar
Best practices
0 votes
2 replies
143 views

I have been exploring the useTransition() hook and the startTransition() method provided by React with version 18+. The documentation states that we can de-prioritize state updates using them so that ...
midhun lc's user avatar
0 votes
0 answers
126 views

In this example from react docs, I can remove use hook from const messageContent = use(messagePromise); leaving it like this const messageContent = messagePromise; and it still works (no error is ...
tautvls's user avatar
  • 27
-2 votes
0 answers
18 views

I am attempting to retrieve a search result from a MySQL database with Axios. res.data is populated with the correct data but when I use my useState setter inside the useEffect, my searchRes variable ...
Ethan Zogg's user avatar
3 votes
1 answer
92 views

I have a modal. This modal opens after a user uploads a CSV. They can then make changes to the entries or delete them. The user can Confirm & Continue (go to next page, modal closes) or Upload New ...
npfist's user avatar
  • 125
3 votes
1 answer
94 views

I'm building a collaborative task management app using React 19's useOptimistic hook. Multiple users can update task properties (status, priority, assignee) simultaneously. I'm running into race ...
Gnaneshwar P's user avatar
0 votes
2 answers
140 views

app/page.tsx "use client"; import { useEffect, useRef } from "react"; import { foo } from "./OrdersModuleFoo"; import React from "react"; const OrdersModule: ...
TSR's user avatar
  • 21.5k
2 votes
1 answer
94 views

This is my structure about code: src App.js pages ConfigurationPage.jsx provider ConfigurationProvider.jsx context ConfigContext.jsx Explain bug: The code is executed 2 times in provider. The ...
ArthurArmand's user avatar
0 votes
1 answer
125 views

I'm using a DynamicForm component with a ref in a React functional component. I want to update the form once my Firebase collection is loaded. Here’s the relevant part of my component: const ...
Emi Buliga's user avatar
-1 votes
1 answer
402 views

When I read the react document, I found a new feature useEffectEvent, which raised a question. If I use responsive variables A and B in useEffect, but I am very sure that it is meaningful to make the ...
zhunbe's user avatar
  • 17
2 votes
1 answer
103 views

Im developing a new app and tried to implement authentication with JWT myself (and with ChatGPT). I will try to explain it as briefly as possible and what I think is happening. // Render the app const ...
ruben450's user avatar
  • 162
0 votes
1 answer
96 views

Can't perform a state update on an unmounted component. I understand that this warning happens when the component unmounts before the asynchronous request finishes, and then setState (or in my case ...
Vishal Mote's user avatar
4 votes
2 answers
153 views

useEffect(() => { console.log("Effect runs"); return () => { console.log("Cleanup runs"); }; }, []); If window.location.reload() is called anywhere in your ...
Bear Bile Farming is Torture's user avatar
2 votes
1 answer
292 views

Could not find a valid source for what's better for this usecase, so... What't better for listening for browser DOM events and changes? the old fashion useEffect+useState or the new ...
Eliav Louski's user avatar
  • 5,622
-1 votes
1 answer
62 views

I have this working component that renders useEffect only once when I open the page with the use of cleanup function export const MyComponent = () => { useEffect(() => { const fetchApi = ()...
Mr. Kenneth's user avatar
  • 1,047
-5 votes
1 answer
94 views

I'm implementing a Sidebar in React with expandable menus and submenus. The state of open menus is managed using an openMenus object in the state, and I'm using react-router-dom for navigation. The ...
Roberto Carlos Melgar's user avatar
0 votes
2 answers
114 views

This may be a simple question but in our UI app we have a pattern my team has used to wrap an object of translation strings from i18next into a state which is never updated. The idea is, the ...
Tanner Summers's user avatar
-1 votes
1 answer
129 views

I'm new to React and trying to build a component using HTML Canvas that draws very simple simulated water ripples. I have my functions working when I manually click buttons but every time I try to ...
dthegnome's user avatar
  • 133
-1 votes
1 answer
108 views

I am trying to use transformers.js to build a simple chatbot to answer questions related to my resume. The error is as below: TypeError: text.split is not a function at closure._encode_text (...
Aditya Singh's user avatar
1 vote
2 answers
109 views

As far as I know, all hooks in React should be called at the top level of a component or custom hook — not inside conditions, loops, or expressions. But I recently stumbled upon a code pattern that ...
koko's user avatar
  • 39
0 votes
0 answers
37 views

I was following along a React project tutorial and writing the exact same code to the last bit but noticed that although the favorited movies would be saved to localStorage, upon refresh the array ...
Мкнр-Владик's user avatar
-1 votes
1 answer
86 views

Let's say I have a variable that depends on a prop, and I declare it in a simple way: const isLeapYear = year % 4 === 0; // year is a prop Now, let's imagine I have a complex function, and I "...
Denis Kramarenko's user avatar
-1 votes
1 answer
91 views

I am using two UseEffect to generate a hypertext effect which scrambles and rearranges itself. First UseEffect is for when it should be animate the text, and the second UseEffect is for how should it ...
Gaurav Ghosh's user avatar
0 votes
2 answers
81 views

perms is an array of objects. Each object is: { catg: 'Catg1' serv: ->array of serv objects { checked: false, desc: 'Serv 1' } } On button click, based on ...
DavidC's user avatar
  • 195
-1 votes
1 answer
71 views

I am trying to make a filehandling system where you can delete the documents from the list of documents with the Delete button next to them. Upon clicking it, the usual pop-up window appears, asking ...
user30266210's user avatar
-1 votes
1 answer
44 views

I’m building a simple character selector in React + TypeScript. I fetch an array of race objects from data.json, store them in state, and let the user cycle forward/backward through them with “...
Bundáskenyér's user avatar
-3 votes
1 answer
208 views

I'm at a loss. No idea whats happening. I have a zustand store set up. Using react router with vite. I'm not even sure why react router is throwing errors becuase this component im trying to finish ...
Chris Williamson's user avatar
1 vote
1 answer
77 views

I use Tanstack Query in my project and have arranged my api interactions like this (see below). Basically I made a custom hook inside which there are other hooks that do data fetching. In my opinion, ...
magrega's user avatar
  • 263
0 votes
1 answer
92 views

I'm using useEffect to fetch data. This data is passed to a state, then used as a prop for a component to render/populate accordingly. Here is the code that works: const [projects, setProjects] = ...
Isaiah Desrosiers's user avatar
1 vote
0 answers
41 views

I have this section of code which will get the profile picture of a user and display it using createObjectURL and release the URL when i navigate away. The problem is that the avatarURL does not hold ...
John Smith's user avatar
0 votes
2 answers
107 views

I'm working on a simple typing effect component in React using Framer Motion. Here's the code for my TypingText component TypingText.jsx import { motion } from 'framer-motion'; import React, { ...
thulhid's user avatar
-1 votes
1 answer
163 views

I am working on a React page that has a built in file manager. I have a DocumentTable.js component, which is responsible for displaying the current list of files available, and it has (among others) ...
user30266210's user avatar
0 votes
2 answers
147 views

I am getting an unexpected behaviour. That is, I have put a skip condition in the query and even when the skip condition is supposed to be true, the query is being run. I have made a minimal ...
suyog's user avatar
  • 159
1 vote
1 answer
36 views

I have read that the rules for using React's hooks are: Don’t call Hooks inside loops, conditions, or nested functions. Instead, always use Hooks at the top level of your React function, before any ...
rjapenga's user avatar
  • 277
3 votes
2 answers
171 views

I would like the ProtectedRoute to call server and get a response that indicates whether the user is logged in or not, on every render of a page that it protects. The server is sent a session cookie ...
user3146945's user avatar
0 votes
1 answer
53 views

I have a table where the last column is a button that triggers an action which in turn queries the DB, returns a result and downloads the result as a csv. In order for the data to be processed and the ...
sinanspd's user avatar
  • 2,744
-1 votes
1 answer
78 views

my route looks like this: <Route path="game/:room_id" element={         <GameProvider>           <Game />         </GameProvider>         } /> Game.jsx(partial) ...
Call_Me_Rhino's user avatar
0 votes
0 answers
140 views

I'm working on updating a large React application ("webapp-front-end") by creating a new module-based redesign. The idea is to gradually migrate and refactor the UI using TypeScript. The new ...
Pedro Bernardes's user avatar
0 votes
1 answer
62 views

I have an app that has a 3 JSX files: one for controlling states import React from "react"; import CreateRisk from "./CreateRisk"; import TablePage from "./TablePage"; ...
Aleks3000's user avatar
-1 votes
1 answer
57 views

I am looking at examples about error boundaries for Next.JS components in the documentation. 'use client' // Error boundaries must be Client Components import { useEffect } from 'react' export ...
Karma Cool's user avatar
0 votes
1 answer
62 views

I'm learning ReactJS, and performance optimisation. I just stumbled on a case I just cannot explain. Below is the smallest code I could write showing the "issue" / strange behavior. I have ...
Jeremy's user avatar
  • 21
3 votes
1 answer
66 views

In a video I saw creating a progress bar and updated its value using state and wrapped it inside setInterval for updating it every 15 millisecond and the whole being wrapped inside useEffect, with no ...
ABISHEK NS's user avatar
1 vote
1 answer
89 views

While learning React, I'm trying to understand custom hooks. I've created a simple one updating an internal "step" on creation, cleanup, and allows for external updates. But I'm struggling ...
Dgurio's user avatar
  • 13
0 votes
1 answer
69 views

I have a custom hook that detects whether a user clicks inside a given element or somewhere else. It works fine when used alone on a single page, but when I use two instances of the hook, the ...
Dhuruv Bansal's user avatar
-1 votes
1 answer
44 views

I'm learning react and typescript. I'm trying to build a todo app with useReducer but im getting some errors. Don't know if they are connected or not. My code is the following import { useReducer, ...
eskimopest's user avatar
0 votes
1 answer
91 views

I'm trying to set up a form with many rows of data, with each individual items. When I click a button, I want to get all of the data from each children, and submit the form. I'm using context to ...
Chris Jeong's user avatar
1 vote
2 answers
285 views

The error happens when I refresh the page or navigate between "/account", "/account/bookings", and "/account/places". import React, { useContext } from 'react'; import { ...
neyuj_11's user avatar

1
2 3 4 5
775