Questions tagged [react-lifecycle]
313 questions
0
votes
2 answers
React Redux cleaning the store - when?
I have an app written in react hooks, I manage my data with redux,
we use redux-persist in order to prevent clean store on each page refresh.
but, I want to clean up the store at the end of application life (close the tab or close all the…

user10391869
- 211
- 3
- 4
- 7
0
votes
0 answers
Component not getting updated after passing of props from parent component
Here is the Radar chart that I want to update.
Currently, I'm working on an application where once we search for a doctor, the radar chart that's being shown in the picture above should get updated based on the new data received through props.…

ShridharK
- 365
- 2
- 14
0
votes
1 answer
React Native detect when user is trying to quit the app?
I want to update my redux state based on the component unmount but in case a user terminates the app how to detect that and update my redux state based on the app termination as the componentWillUnmount will not be called in case of quitting the…

Prince Mittal
- 326
- 3
- 15
0
votes
1 answer
ComponentDidUpdate Variable Not Defined
I'm using prevProps and prevState in my componentDidUpdate method, but it says the variable book isn't defined. However, I've tried different ways of defining it that don't work. I've also seen examples where this is unnecessary. Can someone please…

Elizabeth
- 157
- 1
- 15
0
votes
1 answer
Detect navigation changes
I have a react native App.
I'll like to detect navigation to screens, so when I navigate to a specific screen I trigger a update function. I have the componentDidMount but works only when navigating for the first time... Also have looked at AppState…

Marco Martin
- 185
- 1
- 4
- 18
0
votes
1 answer
Misunderstand using useState react hook - don't work properly
I'm trying to implement private routes according user role permissions. Here is my code:
App.js or routes.js:
} />

RAFAEL DA SILVA
- 99
- 2
- 11
0
votes
2 answers
Issue Converting react class components to functional components with state is undefined
Can life cycles be used in Arrow functions using componentDidMount() and having an error my only response I tried to add a useEffect ? Trying to Converting class components to functional components.
I created a contentful blog in a separate project…

concepttech
- 17
- 2
- 9
0
votes
2 answers
Child Component Not Being Rendered - React
I am going through a react course and currently learning react's lifecycle method. So far, I have been able to call the API using componentDidMount and have set the state. However, I can't seem to get the card components to show the images in the…

Ope Afolabi
- 127
- 12
0
votes
0 answers
why this Error: Too many re-renders. React limits the number of renders to prevent an infinite loop
can anyone help me with this as not working properly maybe there might become a problem in context API I am new to it, please help I think I am missing something in my lifecycle hook, I have tried to use component will mount instead of useEffect but…

Adarsh Goyal
- 13
- 5
0
votes
0 answers
React lifecycle vs window event race condition
I'm hoping someone can shed some light on how React's state and event handlers interact with an event handler set directly on the window object itself(outside of the react lifecycle). For example, in the following code sample we set an event…

louism2
- 350
- 4
- 18
0
votes
3 answers
Why does the code(funtional) for the hook keep rendering? (compared to Class)
I just started react...
This code is simply rendered after 3 seconds using Boolean value.
But the code below keeps rendering.. rendering.. rendering... almost every three seconds.
import React, { useState } from "react";
const App = () => {
const…

Ryong9rrr
- 3
- 1
0
votes
2 answers
React ComponentDidUpdate method fires for each props change partially for multiple props. How to know all props are updated and act accordingly?
I have a react component, say, MyComponent with two props text and num which may change independently. Consider the following code:
componentDidUpdate(prevProps) {
if (this.props.text !== prevProps.text || this.props.num !== prevProps.num) {
…

Sinan
- 1
- 1
0
votes
1 answer
React Hooks and React lifecycle Methods
I am new to reactjs and react native. when started learning the basics, I found various information about the react hooks and react life cycle methods. I know there were 7 lifecycle methods before react 16.3 but now there are just 6 of them. Can…

Ajay Antonyraj
- 19
- 7
0
votes
1 answer
How can I define a method inside a class component in React?
I have made a simple digital clock in React. It seems working. However, I wanted to define the callback function inside the setState() separately. But I got an error. Do you know how I can define such a function called tick() outside the…

Balalayka
- 187
- 2
- 15
0
votes
1 answer
React - When browser start to draw or re-draw which lifecycle method ends?
I'm a react rookie, I just know that React use virtual DOM instead of real DOM, so what I understand is that virtual DOM has one step to mount to real DOM, then browser start to draw, as I know React has lifecycle, what I want to know is that which…

kalends
- 3
- 2