Questions tagged [react-usememo]
169 questions
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
0 answers
Equivalent useMemo async function?
I need to make a HEAVY (needs .then() syntax) API call only ONCE in my app. What I have works, using useState and useEffect, but when the context reloads, it makes the API call again.
Is there a way to rewrite this to work using useMemo, so if the…

wongz
- 3,255
- 2
- 28
- 55
0
votes
1 answer
[react]: useMemo returns first element when passed an array
Here's the sample code
export default function App() {
const [links] = React.useMemo(
() => ['hello', 'world'],[]
)
return (
…

prvnbist
- 431
- 4
- 20
0
votes
1 answer
How can I use data that isn't displayed in a row in React-Table?
For example, I would like to use id as something that would be passed in the Actions header located in the Actions Component via row.values. While I can get the values for first and last name, I cannot for id
const Accounts = () => {
const…
user7806336
0
votes
1 answer
Preventing rerenders with React.memo
I have built a web app where users have profiles with different pages. In all the pages there is a profile picture and a banner and I want them to be rendered only once.
Now, every time the user changes the page the profile picture and banner are…

Jacin
- 71
- 9
0
votes
0 answers
React Table - Cannot access nested JSON object in Cell
I have a problem with react-table.
I need to use subject.subjectName in a different column of the table, but I get an error that the value is empty
columns: [
{
Header: 'Subject Name',
accessor: 'subject.subjectName' // displays properly in…
0
votes
1 answer
React Native Render Buttons
I think I know the issue but I don't have the solution,
so I have these buttons that I create with looping on useState arrray
const [booleanMonth,setMonth]=useState([
{key:0,value:'January',title:'Jan',checked:false},
…

Bzx naga
- 169
- 3
- 13
0
votes
2 answers
useMemo on useState with Array and many Object
My apps run although its kind of slow since I loop to create button and loop again to change the color of the button
Its slow because every time I change a color in a button I have to loop in useState array of objects
My question is, how do I only…

Bzx naga
- 169
- 3
- 13
0
votes
1 answer
Is this one of the use case to use React.useMemo?
Does returning a JSX like below considered as a expensive computation/calculation ? I read a few articles including Kent C Dodds article about when to use useMemo and useCallback. Most of them explicitly say to use those API when your apps feel…

Hud Rosli
- 55
- 3
0
votes
1 answer
React Native Context Content is keep Coming Back
I want to clear user and do logout in React Native using useContext, useReducer, and useMemo.
My App (AuthContext) has Users Screen (UserContext) in it.
UserContext has clearUsers() within useMemo
AuthContext has logout() within…

Jeaf Gilbert
- 11,495
- 19
- 78
- 105
0
votes
3 answers
Why isn't React.useMemo(...) working in my React function?
I'm trying to implement a react-table using this guide:
https://github.com/tannerlinsley/react-table/blob/master/docs/quickstart.md
At one point in the guide, it says to create your data using React.useMemo:
const columns = React.useMemo(
() => [
…

gib65
- 1,709
- 3
- 24
- 58
0
votes
1 answer
Set State cause use memo rerender
Here is the code , no idea why Mem re-render after set state, as it is a memoized component, or if i wanna remember the component with set state, i should use useRef? that stupid??
const Demo = () => {
console.log("render")
const data =…

user192344
- 1,274
- 6
- 22
- 36
0
votes
1 answer
When to not use useMemo?
I am using useMemo to much in my Functional Components, and I am worry about it which will it be a good experience to use it to much in our App?
Why I am using it to much?
I have a to much Components which they dont need to be re-rendered except in…

Muhammad
- 2,572
- 4
- 24
- 46
-1
votes
1 answer
How can I prevent re render of react functional components if no props changed
Description:
I have a component imported in a loop in the Main component and whenever I update the state, the looped components are also re-rendered. So, how can I prevent them to render if no change is applied to the props of the…

Shiv Joshi
- 13
- 2
-1
votes
3 answers
Memoize a function in React
There is a component that receives props.
The props has the shape of an array, for each element of this array, a function is going to return a different component to render.
function MainComponent ({ data }) => { // data is props, an array
const…

Leo Messi
- 5,157
- 14
- 63
- 125