Skip to main content

Questions tagged [react-hooks]

React Hooks are a feature that allows developers to use state(s) and other React component lifecycle features without writing a class-based component.

react-hooks
0 votes
0 answers
6 views

Cannot read properties of null (reading 'useContext') TypeError: Cannot read properties of null (reading 'useContext') When using MUI components

I am new to node and ReactJS and I am trying to use MUI components like https://mui.com/material-ui/react-app-bar/ (Using the 3rd example, I am not editing the code at all) but I keep getting Cannot ...
EXNN's user avatar
  • 1
0 votes
0 answers
30 views

React doesn't renders its child components during batch state updates with child

React renders its child components when the parent renders. But if a render is triggered in both the components by a state change in the same batch then a render in parent component doesn't trigger a ...
Indra's user avatar
  • 13
0 votes
0 answers
10 views

Managing Multiple WebSocket Connections in React with Shared Connections for Components Using the Same URL

I'm working on a React application where I need to manage multiple WebSocket connections. Specifically, I want different components to be able to share a connection if they use the same URL. I'm using ...
MertzAndeas's user avatar
-1 votes
0 answers
8 views

Fix ERROR: TypeError: Cannot read property 'useContext' of null, js engine: hermes & ERROR: Invariant Violation: "main" has not been registered

I'm using React Native to complete an app. The app was working fine on my android emulator up until I tried to add in react-native-svg and react-native-qrcode-svg from npmjs. After adding I was met ...
junbug88's user avatar
0 votes
0 answers
35 views

What is it that useReducer can do that useState can't?

I have a set of product details stored in in Firestore. I've created a custom hook to fetch the product details. The product categories should be displayed in the matching url param. As I add more ...
Fathima M.'s user avatar
0 votes
0 answers
10 views

How can I use mutationfn with a reusable API file

import axios from "axios"; const axiosInstance= axios.create({ baseURL:"https://jsonplaceholder.typicode.com" }) class APIClient<T>{ endpoint:string constructor(...
Razieh's user avatar
  • 1
-1 votes
0 answers
9 views

React useGsap with scrolltrigger not updating actual width of the DOM element

/* eslint-disable @next/next/no-img-element */ "use client"; import { useLayoutEffect, useRef } from "react"; import { useGSAP } from "@gsap/react"; import { ...
Xiaohu Zheng's user avatar
0 votes
0 answers
9 views

Notifee Custom Sound works in foreground, not in background and kill mode in React Native

const queryClient = new QueryClient(); const Root = (props) => { const { hasNotifPermission, requestNotifPermission } = useNotificationsPermission(); useEffect(() => { LogBox....
Awais's user avatar
  • 1
0 votes
2 answers
74 views

useState hook not functioning properly

So I am creating a clone of Google Gemini using React js and I am keeping a useState hook to keep the track of the chat history in the format that gemini API requires (array of objects where each ...
Nihit Jaiswal's user avatar
0 votes
1 answer
61 views

Not able to get inside the for loop in React js

I am making a To-Do App. I am using React frontend, Node backend, and Postgresql DB. I made a component called <TaskLists /> which takes three properties or props: startDate endDate allTasks ...
Aakarshit's user avatar
0 votes
1 answer
33 views

Cannot update state from child element in React (functional components)

I want to have a child component reference and update a state; however, when I try to do so, it only works once or twice before breaking. Strangely, the parent element can still update the state. ...
Kyle Tennison's user avatar
-4 votes
0 answers
21 views

Invariant failed: A state mutation was detected between dispatches [closed]

This is the body of the code const tableHeader = [ { title: "Product name", widthClass: "w-[25%]" }, { title: "Product category", widthClass: "w-[19%...
Iroh Nkechi Omolola's user avatar
0 votes
0 answers
28 views

How to make a tooltip for a column in a table if the text in the column is larger than 250 pixels

I am using tailwind and shadcn for development. My idea is that if the text in a column is larger than a certain number of pixels, it should be possible to see a tooltip from the shadcn library for ...
Артем Лебідь's user avatar
0 votes
1 answer
59 views

Change in locale is not affecting the application

I am creating an application with dayjs as the date-time library. In the application I am setting the default locale to "en" at the app level and when I am changing the language in the ...
lrr59's user avatar
  • 171
0 votes
2 answers
39 views

Working of useSearchDebounce custom react hook

I found this code from this answer https://stackoverflow.com/a/68780417/26420821 How does it work? export function useSearchDebounce(delay = 350) { const [search, setSearch] = useState(null); ...
Baxu's user avatar
  • 1
0 votes
1 answer
21 views

useState returning empty array on default state, using react + supabase

I need help to understand why when I console.log(menus) on Menu.jsx it returns an array of values, but if I console.log(item) it only returns an empty array, while the default value of the item is &...
eko pram's user avatar
0 votes
1 answer
62 views

onClick method not working in my React Project [closed]

I am creating a react eCommerce project everything is done but I'm having troubles in login page I created an account in firebase and configured it to allow user to login via their google account. For ...
The Unique 1's user avatar
0 votes
1 answer
22 views

Keep scroll bar Y position after re-render in react

I tried all other similar questions here but there were about 3 years ago questions and answers which's not working right now. So I have a child component which contains table and in the parent ...
Artem Horbachov's user avatar
0 votes
3 answers
57 views

Multi-line Truncated Text with "..." in the end

I need help with Multi-line Truncated Text. I can't cut the final word with "..." in text block with randon string number So this is my solution which cut the end of my block, but without &...
Nick's user avatar
  • 5
-1 votes
0 answers
21 views

Redux State Does Not Change When Modified From useInterval

so im trying to load user data from localStorage and set it to the redux user state. heres what i have done: Where The User Is Being Used: import Fruit from "../components/Fruit" import { ...
AmirparsaDD's user avatar
0 votes
0 answers
19 views

Does useFormState/useActionState React hook handle multiple requests gracefully like TanStack react-query?

TanStack react-query does a good job handling scenarios where the same request is made multiple times before getting a response. Does React's useActionState (originally called useFormState) hook ...
Snap's user avatar
  • 649
1 vote
0 answers
16 views

Cant put tsparticle.js component on each carousel slide of React.js

I am using the tsparticle.js with React and Tailwind css for design in my code in the carousel slides but i cant see that on each slide. It appears only on first slide. The rest of the slides are ...
B ANURAG's user avatar
-4 votes
1 answer
45 views

I want to prevent my React app from Security Vulnerability [closed]

I am getting 7 security vulnerabilities (4 High and 3 Moderate). I didn't find any solution to fix those. I am getting those vulnerabilities with Checkmarx Application Security Testing Tool. Below are ...
Mrityunjay Yadav's user avatar
0 votes
1 answer
33 views

Unable to pass prop to api function from UseEffect in React Next.js

Just for full context, I am using App Router in next.js. I am having trouble passing 'serial_num' as an argument to my api function "fetchImages" when I am trying to trigger it from inside ...
serdar_bay's user avatar
0 votes
0 answers
25 views

Why context variables do not update automatically in other contexts/components? [closed]

My problem in short: I use 2 contexts, the first one consumes an array from the second. It looks like when the second updates this array, the first context still holds the old state... Long version: ...
Yohan Attal's user avatar
0 votes
1 answer
30 views

For loop in react using cards

I'm working on recipe project . I have fetch the all data from an API like image ,video ,ingredients into the react cards. Now i want to the Ingredients for each card as per need . For example card1 ...
Priya Prajapati's user avatar
0 votes
1 answer
49 views

Default Values vs. undefined in React TypeScript Context

In React with TypeScript, should we define default values for context, or should we allow the context value to be undefined? Which is generally recommended for better type safety, performance, ...
Arshia.O's user avatar
-1 votes
2 answers
32 views

The state is not updating correctly inside setInterval of useEffect in react

I'm facing issue in updating the setStartTime inside setInterval function. I want to update the startTime every minute. To update that, I've created a useRef and storing the value in timeRef.current. ...
Amrit Anand's user avatar
-2 votes
0 answers
29 views

invalid hook call. Hooks can only be called inside of the body of a function component. this of the fowwing reason

Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the ...
Karn Kumar's user avatar
0 votes
1 answer
35 views

React Form Input Value Does Not Update Passed One Value onChange

I have a very basic react page to update a data structure: list and send the update to a database. Some context for the snippet below: a list is just a basic structure that contains 2 values and an ...
Phillip Radke's user avatar

15 30 50 per page
1
2 3 4 5
1031