Questions tagged [usecallback]

251 questions
0
votes
0 answers

My object doesn't render, is it because of the scope of the recipeID variable? Or did I do something else wrong?

Ive been trying to wrap my head around this as its bugging me. Recipe is taking in recipeID via useParams() and I am using it to filter and find the matching recipe. For some reason its not returning an object to render. I can trace it where I call…
Brad G.
  • 93
  • 1
  • 12
0
votes
0 answers

Passing values from a constant to the e.target.value

I am working on building out a radio component and when checked I want the values from the radio button to pass when set onBlur. I am trying to pass a function to the onBlur but I am not seeing the values on my Form Submit action. const [isChecked,…
0
votes
0 answers

The useCallBack in react not work as expected

I have a question about useCallBack in react? In useEffect I fetch data and set listDrawPath to context, first listDrawPath is array null [], after finish set listDrawPath second listDrawPath contains object as expected, but in function…
0
votes
2 answers

how to avoid rerender due to useCallback dependency change

I have a VideoPlayer component with crop functionality that's not working well after migration to functional over class component. The VideoPlayer has a isVideoPlaying state (useState). It also contains a function toggleOrChangeIsVideoPlaying: const…
0
votes
0 answers

JavaScript Handling Promise Response and Saving the response to MYSQL (PHP)

So I have this pre-built Javascript from Vendor which only returns Promise (https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt). Now that I managed to get the response into Console.log. I wish to save this Response to mysql using…
0
votes
0 answers

useCallback with a parameter solution

I have some kind of dropdown controlled component, something like that: const [dropdownValue, setDropdownValue] = useState(""); setDropdownValue(value)}/> (I want the onChange method to do more…
Eliot
  • 37
  • 5
0
votes
1 answer

Is useCallback needed every-time a function is passed to a child component?

I am trying to better understand when and where useCallback is needed when passing functions to child components. I have a function declared in my parent component that redirects to a different page altogether. Trigger on a button click const…
Ben Shekhtman
  • 385
  • 5
  • 15
0
votes
2 answers

Use React props as a function argument

I want to check if this is good practice, and if there's a better approach to it. I have a function that is called when the component loads and when clicking on a couple of buttons, so I need to use it inside useEffect, and pass it to other…
Guido Glielmi
  • 73
  • 1
  • 5
0
votes
2 answers

Why does my Card List Component Re-renders on every change

I do understand useEffect, perhaps not entirely , but due to some warnings, I re-structured some of my functions with useCallBack and that seemed to resolve the warning issue. The thing is I don't understand useCallBack fully, and due to tight…
Gret
  • 3
  • 2
0
votes
1 answer

utility function with useCallback

I have a simple function with a useCallback in three part of my app to set an image: const myLittleFunction = useCallback((image: string | undefined) => { mySetState(image) }, [ mySetState, ]) this function is used to retrieve an image…
E.D
  • 831
  • 3
  • 16
  • 33
0
votes
2 answers

Usecallback fail to memorization

I have the following code where changes on the parent component cause child element re - render. Basically the Menu component should be appear by right click on top of the placeholder tag but when it appears the whole parent component flickers. I…
zEn feeLo
  • 1,877
  • 4
  • 25
  • 45
0
votes
2 answers

React useEffect causing function to run 7 times. I am using a useCallback but it still runs to many times

The updateAddedState function with the console.log("running") is running 7 times on a page refresh/initial render. I only want the updateAddedState function to run once when the addedItems state updates. I only what the useEffect to run when the…
0
votes
1 answer

How to properly fix React Hook useCallback has a missing dependency

I updated my Eslint rules using airbnb in my React typescript project. I get those errors now: React Hook useCallback has a missing dependency: 'setCookie'. Either include it or remove the dependency array.eslintreact-hooks/exhaustive-deps I have…
meez
  • 3,783
  • 5
  • 37
  • 91
0
votes
0 answers

How to update the state inside a function wrapped in useCallback hook

Having the following component: import { useMemo, useState, useEffect, useCallback } from 'react'; import { CellProps } from 'react-table'; import { useDataTable, DataTable, useOnRowClick, useRowHighlight, IconMenu } from…
Leo Messi
  • 5,157
  • 14
  • 63
  • 125
0
votes
2 answers

How to solve React rerenderign issue

have sum function and sum as dependency of useEffect. whenever the input change console.log("sum is") printed. console.log("sum is") is not printed when there is no dependency in useEffect even if input change. it is because of when input change it…