Questions tagged [react-lifecycle]
313 questions
0
votes
0 answers
Duplicated reponse with Axios in React component's lifecycle method
I'm making a web application and configured a Django backend server to which I make API calls with axios.get. The problem is, the middleware code is being executed twice and I don't understand why, I'm using the API call within a React component's…

R. Alberto
- 3
- 3
0
votes
1 answer
Is returning `true` in shouldComponentUpdate the same as not having shouldComponentUdpate?
In my React Native component, I added an empty shouldComponentUpdate
shouldComponentUpdate(nextProps, nextState) {
}
I know from this answer that having an empty shouldComponentUpdate results in eliminating all unnecessary re-renders. If I…

gkeenley
- 6,088
- 8
- 54
- 129
0
votes
2 answers
componentDidUpdate is not fired
In my source code, the height of the component EditorBasic that I measure by .current.clientHeight changes when resizing the window, which is not correct. To reproduce the bug, I wrote the following smaller code.
I used aRef to refer to EditorBasic…

SoftTimur
- 5,630
- 38
- 140
- 292
0
votes
1 answer
I need to listen update phase (in life cycle) without constantly sending get requests in react JS
I am trying to write a program that communicates with the client frequently and I need to quickly notice the changes and read the result from the server. But this request is constantly being sent and loaded, even when the user is not interacting.…

mohsen bahrami
- 1
- 1
0
votes
1 answer
React Native: Flatlist rendered component state renders wrong data?
A bit hard to explain, so I have this flat list,
(
…

marko
- 1,721
- 15
- 25
0
votes
0 answers
How to keep a React component running in the background for report generation while navigating to other screens?
I am generating a report for multiple datasets by overlaying WMS images from GeoServer as a slideshow and taking screenshots using the html2canvas library.
The problem is that if the user navigates to another component or screen, then the slideshow…

Abhilash
- 43
- 1
- 8
0
votes
0 answers
How to paginate data from api?
I'm working on a project using react (next.js) and I can get data from Api perfectly, but for some reasons (performance and ...) the Api doesn't return the whole data and I should get one slice of the data time to time until the Api method returns…

bami
- 211
- 1
- 6
- 19
0
votes
1 answer
React: How to update parent component's useEffect hook when using routes
I use the useEffect hook to dispatch the getQuestions function in order to get the data from the server
function App () {
const dispatch = useDispatch();
useEffect(() => {
dispatch(getQuestions());
}, [dispatch]);
return (
…

Synchro
- 1,105
- 3
- 14
- 44
0
votes
0 answers
React 18 unexpected behaviour component mount, unmount and then remount
We switched to React 18 from react 17. Strangely all the API code that is running during component mount in useEffect has started executing twice. When we applied console we found that it look like component mounting, then unmount and then…

Yatin Gupta
- 29
- 3
0
votes
1 answer
React componentWillUnmount() stops setInterval when the timer hits at 7
Unable to stop setInterval in react using componentWillUnmount() when the timer hits at 7
class component
export default class App extends React.Component{
constructor(props){
super(props);
this.state={
counter:0
}
}
…

Syed
- 1
0
votes
1 answer
component useEffect setState for two parentComponent at the same time
I have a screen that navigates to another screen. Both uses same stateful component that should set a state for whichever screen it was called. But in my case, I am navigating to the second screen and then uses the stateful component there.
The…

user13080475
- 11
- 2
0
votes
1 answer
In react world, when does props changing happen? It's definitely triggered by parent component re-rendering?
When it comes to thinking about possibility of props changing, should I only care about parent component updating? Any other possible cases exist for props changing?
I can guess only one case like the code below. I would like to know if other cases…

iamippei
- 148
- 9
0
votes
1 answer
Measuring a DOM node
I know that calling setState() immediately in componentDidMount() is a performance issue and it is better to use the constructor in some cases.
But in the last sentence of the React documentation it talks about a USE CASE that states that calling…
user19551894
0
votes
1 answer
setState() in componentDidMount() - When is the intermediate state REALLY noticeable TO THE USER?
The React doc states that the intermediate state will not be shown to the user, but why in this example it does show "loading...." (the intermediate state in this case)?
You may call setState() immediately in componentDidMount(). It will
trigger an…
user19481364
0
votes
2 answers
React ref callback updating 'this' to update child props not working
I've been hitting the issue mentioned in this thread where, when using the ref callback the refs are updating AFTER componentDidMount.
Apparently this can happen when you pass refs to elements that are being passed to a component as children, but I…

Weardian
- 211
- 4
- 13