Questions tagged [usecallback]
251 questions
0
votes
1 answer
TypeError: undefined is not a function (near '...(0, _react.useCallBack)...'). I don't know what's wrong with the usCallBack() function in my code
I am getting this error if I am using useCallBack() in my code and after removing it then my filterScreen.js doesn't work.
I am trying to get and save the params in "save" using react-navigation and printing the values of filters in the…

Harsh Mishra
- 862
- 3
- 15
- 29
0
votes
0 answers
Using React DropZone but callback does not update
I am trying to use React Dropzone but the callback does not get triggered or updated when the state gets updated. I even tried adding a seperate useCallback. Any help much appriciated
Code Sandbox link…

Zinox
- 519
- 9
- 24
0
votes
0 answers
React useCallback - I can't update my function
I want to update my callback function:
const getSchema = React.useCallback(
() => {
const schema = twSchema(
labels,
isInitialWarehouseActive ? initialWarehouse.id : undefined,
…

Matley
- 1,953
- 4
- 35
- 73
0
votes
1 answer
Call a function on state change *and* on button click
I have a table I need to generate based on 4 inputs. The inputs need to be filled out and then a button must be clicked for the table to generate. Also, the table should re-generate if the page is changed. So basically, I need the function to run…

muke01
- 1
- 1
0
votes
1 answer
useEffect cleanup / memory leak
I have wrote a ReactJS web application. This is a Single Page Application (SPA).
I have a menu with several Pages. Each page is a .js file.
Due to SPA, my browser is not refreshing full page when i change page in my menu.
Here is what i put on every…

Bob5421
- 7,757
- 14
- 81
- 175
0
votes
0 answers
useEffect and useCallback causes multiple rerenders
I was working on a little project of mine and just before deployment, the API i was using made a policy change to limit API calls to one/second. This led to me having an error(Error 429 : too many request).
My work around(as axios doesn't have a…

Chidex
- 139
- 2
- 10
0
votes
2 answers
React hook useCallback with get API call inside useEffect not behaving correctly
I want to achieve the following.
Action from redux is imported in this component. It fetches data from firebase, which I use as a database. Data is displayed inside this component.
My problem is that data is fetched every time component is mounted,…

Chaka15
- 1,105
- 1
- 8
- 24
0
votes
2 answers
React useCallback() function in Parent is only working fine with Child if React.memo is used, without it not working
Parent Component
The parent component contains input which on change sets the state "local" and a button which on click takes this "local" state's value and sets it to "sendLocal"
Functions
changehandler : triggers on input type…

fahad saleem
- 616
- 6
- 8
0
votes
0 answers
Re-rendering Screen using useEffect
I have been stuck on this issue for a long time and need some help solving it.
I am building a kind of a sales app and trying to set all together in one page so user can get his achievement versus his target
In this screen I am trying to set a…

Hatim Fayez
- 181
- 1
- 2
- 17
0
votes
1 answer
useCallback in React seems to be not letting me update state in parent
I've created a simple example of how useCallback is not allowing me to preserve state changes. When I remove the useCallback, the counters that I store in state update as expected, but adding useCallback (which I was hoping would keep rerenders of…

Pete
- 3,111
- 6
- 20
- 43
0
votes
1 answer
Carry Page context/state across components using react hooks
I am new to react hooks. We are developing a react based application without redux. We have a single page where we have different components like search, filters, grid, pagination etc.
Whenever we does any action on page , Grid should get refreshed…

user8599269
- 241
- 1
- 11
0
votes
2 answers
React useCallback() and useEffect on event-handler keeps re - rendering
I am learning react from helinski fsopen20.
One of the exercises requires to click a button and show the weather of that button bound region.
The button has an onClick event that takes index of regions as the parameter to determine which region is…

ribash sharma
- 71
- 12
0
votes
2 answers
useCallback with dependency vs using a ref to call the last version of the function
While doing a code review, I came across this custom hook:
import { useRef, useEffect, useCallback } from 'react'
export default function useLastVersion (func) {
const ref = useRef()
useEffect(() => {
ref.current = func
}, [func])
…

Maxime Chéramy
- 17,761
- 8
- 54
- 75
0
votes
1 answer
how to avoid all child component re-render without override shouldComponentUpdate in child component
It is a quite common scenario, we have a table with huge data. It has a check box for each row which used to exporting data from selected row.
in App.tsx,
const App = () => {
const [selection, setSelection] = useState([]);
const…

smilingky
- 379
- 3
- 4
0
votes
1 answer
Unable to acess a Function with parameters inside of UseCallback
I have this page (screen) that receives via Params an ID number, in this Screen, I try to call an Action Function from my Action (reducer) file and gets an API call, I thought I didn't get any information in the Array from that call, I believe that…

Rene Alas
- 481
- 4
- 14