Questions tagged [react-usecallback]
57 questions
1
vote
1 answer
Why are snapPoints memorizades with useMemo react-native-bottom-sheet
Why the documentation use useCallback and useMemo to memorize the props passed for the BottomSheet, what the performance win with this?
https://gorhom.github.io/react-native-bottom-sheet/usage
import React, { useCallback, useMemo, useRef } from…

Luis Antonio tonhao_dev
- 123
- 1
- 7
1
vote
0 answers
Are there performance gains for useCallback and useMemo with redux-toolkit?
I've seen a lot of descriptions of why you shouldn't use React's useCallback with an empty dependency list (which makes logical sense), but I'm stuck trying to figure out if there are performance gains when using it alongside redux-toolkit, when the…

sernaferna
- 314
- 1
- 6
- 15
0
votes
0 answers
Trouble Understanding React.memo on a Component
Please take a look at the following code
// index.jsx
import React from 'react';
import {data} from '../../../../data.js';
import List from './List.jsx';
const peopleContext = React.createContext();
export const usePeopleContext = () =>…

Bop 1ABot
- 1
- 1
0
votes
0 answers
When i run the npm run dev function following error is printed on the console
error ./node_modules/@radix-ui/react-compose-refs/dist/index.mjs
Attempted import error: 'useCallback' is not exported from 'react' (imported as '$3vqmr$useCallback').
does anyone know how to fix this issue
i have tried various solutions from…
0
votes
1 answer
Why is this callback not being memoized in React?
I have a Next.js project with the following code in _app.tsx:
const Root = ({ Component, pageProps }) => {
...
const handleHistoryChange = useCallback((url) => {
console.log({ url });
}, []);
useEffect(() => {
…

zkwsk
- 1,960
- 4
- 26
- 34
0
votes
1 answer
Array is re-rendered with each tap in the input field
I have the problem that when I enter something in the title field, the preview array is re-rendered for each letter. Anyway, the images are rearranged with each typing. I have no idea what the problem is.
emphasized text
const [imagePreviews,…

Captai-N
- 1,124
- 3
- 15
- 26
0
votes
0 answers
useCallback function issue in react
In this code, the searchText is showing in the console from outside of the handleFetchExams function. Why searchText value is not coming inside the handleFetchExams function? Please help me to bring the searchText value inside the handleFetchExams…

Rakibul Hassan
- 1
- 2
0
votes
0 answers
Why sending json message in webSocket caused a lot re-render in react app
I have a form that want to send message via webSocket when click on submit button but after click and send message my component repeats in a cycle and my console shows a lot of console.log; I tried everything and only send message caused that; what…

N.SH
- 616
- 7
- 20
0
votes
0 answers
React : using "useCallback", do I have to reference as deps the Input of a inner setData(input => ...)?
Learning React and in particular memoization and useCallback hook and I have a doubt about something.
Here is my snippet :
const updateCardImage = useCallback((event) => {
const file = event.target.files[0];
const reader = new FileReader();
…

Jonathan Schoreels
- 1,660
- 1
- 12
- 20
0
votes
1 answer
React Hook useCallback() with useState var not updating state
I have a react-native app that has boolean values to render certain components but the state is not updating in useCallback
export const Foo = (props): => {
const value = undefined
const [bar, setBar] = useState(false)
…

Wayne Filmater
- 21
- 3
0
votes
1 answer
Is it possible to stop calling useCallback when dependency changes?
I have a page that has multiple pages that contains some data, the way it works is that we take the sorting method, and the current page number, and use them in the params when fetching data, like this:
const [Sorting, setSorting] =…

lamsmallsmall
- 105
- 7
0
votes
0 answers
Tip Tap setContent function isnt working in Next-Ts
Trying to create a PWA note app and using tiptap in it. I'm trying to save content in localStorage to be able to run the app in offline mode and save content in the database whenever the user is back online.
The content is stored successfully in…

Abolfazl Ghodrati
- 11
- 4
0
votes
2 answers
useEffects keeps looping for infinity
Pardon me if this is a silly question. Im a new react learner. Im trying using a create react app. I am using a custom hook for API handling only. Now I want the useEffect to run only when the data changes. Thats why I put it in dependency. But yet…

Cnerd Mahadi
- 21
- 4
0
votes
2 answers
How to get rid of this infinite loop using useEffect and useCallback?
I wanna load the first batch of comments immediately (using useEffect) and then load additional pages when a "load more" button is pressed.
The problem is that my current setup causes an infinite loop (caused by the dependency on comments).
If I…

Florian Walther
- 6,237
- 5
- 46
- 104
0
votes
0 answers
How should I approach this situation in React with Childs getting data from an API?
I decided to learn React during the winter holidays and decided that I would like to consume an API designed to create and list comments.
By following the React documentation, I achieved to create comments and get them via an API call using axios…

BadProgrammer
- 83
- 6